GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Aug 31, 2014 4:15 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Setting Mouse Cursor in GtkTreeView
PostPosted: Mon Oct 08, 2012 3:08 pm 
Offline

Joined: Wed Jun 27, 2012 8:29 pm
Posts: 4
Hi,
I am trying to change the mouse cursor of a textview widget. Here is what i have tried so far:

Code:
#include <gtk/gtk.h>

GtkWidget *Add_To_Scrolled_Window(GtkWidget *widget,int width,int height)
{
   GtkWidget *scrolled_window;
   
   scrolled_window = gtk_scrolled_window_new(NULL,NULL);
   
   if(height != 0 && width != 0)
      gtk_widget_set_size_request(widget,width,height);
   
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
   
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),GTK_SHADOW_IN);

   gtk_container_add(GTK_CONTAINER(scrolled_window),widget);

   return scrolled_window;
}

void Title_Box(GtkWidget *vbox,char *title_msg)
{
   GtkWidget     *scrolled_window,*textview;
   GtkTextBuffer *buffer;
   GtkTextIter   iter;
   GdkCursor     *cur;
   GdkWindow     *window;
   
   textview = gtk_text_view_new();
   buffer    = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
   cur      = gdk_cursor_new(GDK_ARROW);   
      
   window   = gtk_text_view_get_window (GTK_TEXT_VIEW(textview),
            GTK_TEXT_WINDOW_TEXT);
   
   gdk_window_set_cursor(window, cur);

   gtk_text_buffer_create_tag(buffer,"title","foreground","blue",NULL);   

   gtk_text_buffer_get_iter_at_offset(buffer,&iter,10);

   gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,title_msg,-1,"title",NULL);
   
   g_object_set(G_OBJECT(textview),"cursor-visible",FALSE,"editable",FALSE,NULL);

   scrolled_window = Add_To_Scrolled_Window(textview,0,0);
   
   gtk_box_pack_start(GTK_BOX(vbox),scrolled_window,TRUE,TRUE,TRUE);
}


int main(int argc,char **argv)
{
   GtkWidget *entry_option,*main_box;

   gtk_init(&argc,&argv);

   entry_option  = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   main_box      = gtk_vbox_new(FALSE,10);
   
   gtk_widget_set_size_request(entry_option,750,-1);
      
   Title_Box(main_box,"Text View Mouse Cursor Test");

   gtk_container_set_border_width(GTK_CONTAINER(entry_option),20);
   
   gtk_container_add(GTK_CONTAINER(entry_option),main_box);
   
   gtk_widget_show_all(entry_option);

   gtk_main();

   return 0;
}


Its not working. I searched the forum,but none of the answer is working for me. Any help would be appreciated.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group