static GtkWidget * get_desktop_manager_selection (GdkScreen *screen) { char selection_name[32]; GdkAtom selection_atom; Window selection_owner; GdkDisplay *display; GtkWidget *selection_widget; g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S%d", gdk_screen_get_number (screen)); selection_atom = gdk_atom_intern (selection_name, FALSE); display = gdk_screen_get_display (screen); selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), gdk_x11_atom_to_xatom_for_display (display, selection_atom)); if (selection_owner != None) { return NULL; } selection_widget = gtk_invisible_new_for_screen (screen); /* We need this for gdk_x11_get_server_time() */ gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK); if (gtk_selection_owner_set_for_display (display, selection_widget, selection_atom, gdk_x11_get_server_time (gtk_widget_get_window (selection_widget)))) { g_signal_connect (selection_widget, "selection-get", G_CALLBACK (selection_get_cb), NULL); return selection_widget; } gtk_widget_destroy (selection_widget); return NULL; }
static VALUE gtkdrag_selection_owner_set(int argc, VALUE *argv, VALUE self) { gboolean ret; if (argc == 3){ VALUE widget, selection, time; rb_scan_args(argc, argv, "30", &widget, &selection, &time); ret = gtk_selection_owner_set(RVAL2WIDGET(widget), RVAL2ATOM(selection), NUM2INT(time)); } else { #if GTK_CHECK_VERSION(2,2,0) VALUE display, widget, selection, time; rb_scan_args(argc, argv, "40", &display, &widget, &selection, &time); ret = gtk_selection_owner_set_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), RVAL2WIDGET(widget), RVAL2ATOM(selection), NUM2INT(time)); #else rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); #endif } return CBOOL2RVAL(ret); }