LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gdk change cursor (https://www.linuxquestions.org/questions/programming-9/gdk-change-cursor-564942/)

cyb0rg777 06-27-2007 05:32 PM

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?

cyb0rg777 06-28-2007 08:40 AM

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.


All times are GMT -5. The time now is 05:02 PM.