LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-27-2007, 05:32 PM   #1
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Rep: Reputation: 15
gdk change cursor


I'm working on a graphics program.My program has a gtkiconview that is filled with icons.Whenever a part is clicked I want the part to float with the cursor.So I am changing the cursor to the picture stored in the treemodel.I'm not sure if there is a better way to do this or not.I just want to drag and drop the parts from one window to another except without having to hold the mouse button.

I'm stuck at changing the cursor to the icon image in the other window.Here is about what I have now ,which doesn't work.
Code:
cursor=gdk_pixbuf_new(GDK_COLORSPACE_RGB,1,8,200,200);
cursor_map=gdk_pixmap_new(NULL,200,200,24);
mask=gdk_pixmap_new(NULL,200,200,24);

  /*get selected image*/
part=gdk_pixbuf_new(GDK_COLORSPACE_RGB,1,8,200,200);
selected = gtk_icon_view_get_selected_items(GTK_ICON_VIEW(iconview1));
if(!selected)g_print("no selection");
model = gtk_icon_view_get_model (iconview1);
gtk_tree_model_get_iter (model, &iter, selected->data);
gtk_tree_model_get(model,&iter,0,part,-1);

gdk_draw_pixbuf(cursor_map,NULL,cursor,0,0,0,0,200,200,GDK_RGB_DITHER_NORMAL,0,0);
gdk_cursor_new_from_pixmap(cursor_map,mask,&fg,&bg,0,0);
gdk_window_set_cursor(gwindow,cursor);
gwindow=gdk_window_new(NULL,&watrib,GDK_WA_CURSOR);

/*destroy the list*/
g_list_foreach (selected, gtk_tree_path_free, NULL);
g_list_free (selected);

/*destroy the widget*/
gtk_widget_destroy(icon_parts);
the error I'm getting is this right now.

Gdk-WARNING **: gdkwindow-x11.c:817cannot make windows of type 140

Anyone know how to do this?
 
Old 06-28-2007, 08:40 AM   #2
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143

Original Poster
Blog Entries: 8

Rep: Reputation: 15
I found a better way to do it .GTK has a lot of built in drag and drop functions.

I added this code to my iconview.
Code:
  gtk_icon_view_enable_model_drag_source(iconview1,
                                        GDK_BUTTON1_MASK,
                                        item_targets,
                                        G_N_ELEMENTS(item_targets),
                                        GDK_ACTION_COPY);

gtk_drag_source_add_image_targets(iconview1);
And this code to my canvas.

Code:
gtk_drag_dest_set(canvas1,
                  GTK_DEST_DEFAULT_ALL,
                  item_targets,
                  G_N_ELEMENTS(item_targets),
                  GDK_ACTION_COPY);


gtk_drag_dest_add_image_targets(canvas1);
So far it looks like it drags and drops but it isn't copying.
 
  


Reply

Tags
drop


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide mouse cursor/change cursor location? mrjamin Linux - Software 4 09-27-2010 10:09 AM
mouse cursor change ygloo Linux - General 9 01-15-2007 05:12 PM
how to change cursor in emacs? breadbin Linux - Software 1 10-06-2006 06:24 PM
X mouse cursor change horndude Slackware 1 12-19-2004 01:56 AM
Change a cursor Kroenecker Linux - Newbie 1 08-22-2003 12:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration