GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Nov 28, 2014 12:15 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: how to hide cursor in gtk text entry
PostPosted: Tue Feb 24, 2009 12:42 pm 
Offline
Familiar Face

Joined: Thu Feb 12, 2009 6:14 am
Posts: 39
how to hide cursor in gtk text entry


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 8:04 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
I don't know any way to do it exactly so, but may be you should use GtkLabel?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 3:50 pm 
Offline
GTK+ Geek

Joined: Thu Dec 20, 2007 5:24 pm
Posts: 56
Location: Turkey
What do you want to do exactly? Do you want not to show the cursor but other properties to remain? Or do you want to make it not editable. If latter, you can use gtk_editable_set_editable ():

http://library.gnome.org/devel/gtk/stab ... t-editable


Top
 Profile  
 
 Post subject: Re: how to hide cursor in gtk text entry
PostPosted: Mon Dec 12, 2011 8:23 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
I know this is a pretty old post but there's not enough information out there about GTK+3 anyway. Setting gtk_editable_set_editable doesn't hide the cursor. At least not in GtkEntry. If you want to hide it you can just change it to the background color. Using CSS with Gtk-3.2.0 you use -GtkWidget-cursor-color like this:
Code:
/*  Compile With:    gcc -Wall -o cursor `pkg-config --cflags --libs gtk+-3.0` cursor.c */

#include <gtk/gtk.h>

int main (int argc, char* argv[])
{
  GtkWidget *window;
  GtkWidget *tview;
  GtkTextBuffer *tbuf;
  GtkCssProvider *provider; // for css
  GdkDisplay *display;      // for css
  GdkScreen *screen;        // for css

  gtk_init(&argc, &argv);

/*-------------  CSS  --------------------------------------------------------------------------------------*/
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider,
                                   "GtkTextView {color: blue; font: Serif 38; background-color: yellow; -GtkWidget-cursor-color: red}",-1,NULL);

  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);
  gtk_style_context_add_provider_for_screen (screen,
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
  g_object_unref (provider);
/*-------------  CSS  --------------------------------------------------------------------------------------*/

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 500, 250);
  g_signal_connect_swapped(G_OBJECT(window), "destroy",
      G_CALLBACK(gtk_main_quit), NULL);

   tbuf = gtk_text_buffer_new(NULL);
   tview = gtk_text_view_new_with_buffer (tbuf);
   gtk_container_add(GTK_CONTAINER(window), tview);

  gtk_widget_show_all(window);
  gtk_main();
  return 0;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group