void panel_action_button_set_dnd_enabled (PanelActionButton *button, gboolean enabled) { g_return_if_fail (PANEL_IS_ACTION_BUTTON (button)); if (!button->priv->type) return; /* wait until we know what type it is */ enabled = enabled != FALSE; if (button->priv->dnd_enabled == enabled) return; if (enabled) { static GtkTargetEntry dnd_targets [] = { { "application/x-mate-panel-applet-internal", 0, 0 } }; gtk_widget_set_has_window (GTK_WIDGET (button), TRUE); gtk_drag_source_set (GTK_WIDGET (button), GDK_BUTTON1_MASK, dnd_targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); if (actions [button->priv->type].icon_name != NULL) gtk_drag_source_set_icon_name (GTK_WIDGET (button), actions [button->priv->type].icon_name); gtk_widget_set_has_window (GTK_WIDGET (button), FALSE); } else gtk_drag_source_unset (GTK_WIDGET (button)); button->priv->dnd_enabled = enabled; g_object_notify (G_OBJECT (button), "dnd-enabled"); }
void panel_menu_button_set_dnd_enabled (PanelMenuButton *button, gboolean dnd_enabled) { g_return_if_fail (PANEL_IS_MENU_BUTTON (button)); dnd_enabled = dnd_enabled != FALSE; if (button->priv->dnd_enabled == dnd_enabled) return; if (dnd_enabled) { static GtkTargetEntry dnd_targets [] = { { "application/x-mate-panel-applet-internal", 0, 0 } }; char *icon; gtk_widget_set_has_window (GTK_WIDGET (button), TRUE); gtk_drag_source_set (GTK_WIDGET (button), GDK_BUTTON1_MASK, dnd_targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); icon = panel_menu_button_get_icon (button); if (icon != NULL) { gtk_drag_source_set_icon_name (GTK_WIDGET (button), icon); g_free (icon); } gtk_widget_set_has_window (GTK_WIDGET (button), FALSE); } else gtk_drag_source_unset (GTK_WIDGET (button)); }
static int gtkSetDragSourceAttrib(Ihandle* ih, const char* value) { if (iupStrBoolean(value)) { GtkTargetList *targetlist = (GtkTargetList*)iupAttribGet(ih, "_IUPGTK_DRAG_TARGETLIST"); GtkTargetEntry *drag_types_entry; int targetlist_count; if(!targetlist) return 0; drag_types_entry = gtk_target_table_new_from_list(targetlist, &targetlist_count); gtk_drag_source_set(ih->handle, GDK_BUTTON1_MASK, drag_types_entry, targetlist_count, iupAttribGetBoolean(ih, "DRAGSOURCEMOVE")? GDK_ACTION_MOVE|GDK_ACTION_COPY: GDK_ACTION_COPY); g_signal_connect(ih->handle, "drag_begin", G_CALLBACK(gtkDragBegin), ih); g_signal_connect(ih->handle, "drag_data_get", G_CALLBACK(gtkDragDataGet), ih); g_signal_connect(ih->handle, "drag_end", G_CALLBACK(gtkDragEnd), ih); gtk_target_table_free(drag_types_entry, targetlist_count); } else gtk_drag_source_unset(ih->handle); return 1; }
void panel_launcher_set_dnd_enabled (Launcher *launcher, gboolean dnd_enabled) { GdkPixbuf *pixbuf; if (dnd_enabled) { static GtkTargetEntry dnd_targets[] = { { (gchar *) "application/x-panel-icon-internal", 0, TARGET_ICON_INTERNAL }, { (gchar *) "text/uri-list", 0, TARGET_URI_LIST } }; gtk_widget_set_has_window (launcher->button, TRUE); gtk_drag_source_set (launcher->button, GDK_BUTTON1_MASK, dnd_targets, 2, GDK_ACTION_COPY | GDK_ACTION_MOVE); //FIXME: this doesn't work since the pixbuf isn't loaded yet pixbuf = button_widget_get_pixbuf (BUTTON_WIDGET (launcher->button)); if (pixbuf) { gtk_drag_source_set_icon_pixbuf (launcher->button, pixbuf); g_object_unref (pixbuf); } gtk_widget_set_has_window (launcher->button, FALSE); } else gtk_drag_source_unset (launcher->button); }
int clip_GTK_DRAGSOURCEUNSET(ClipMachine * cm) { C_widget *cwid = _fetch_cw_arg(cm); CHECKCWID(cwid, GTK_IS_WIDGET); gtk_drag_source_unset(GTK_WIDGET(cwid->widget)); return 0; err: return 1; }
static void set_features (EmpathyPersonaView *self, EmpathyPersonaViewFeatureFlags features) { EmpathyPersonaViewPriv *priv = GET_PRIV (self); priv->features = features; /* Setting reorderable is a hack that gets us row previews as drag icons for free. We override all the drag handlers. It's tricky to get the position of the drag icon right in drag_begin. GtkTreeView has special voodoo for it, so we let it do the voodoo that he do (but only if dragging is enabled). */ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (self), (features & EMPATHY_PERSONA_VIEW_FEATURE_PERSONA_DRAG)); /* Update DnD source/dest */ if (features & EMPATHY_PERSONA_VIEW_FEATURE_PERSONA_DRAG) { gtk_drag_source_set (GTK_WIDGET (self), GDK_BUTTON1_MASK, drag_types_source, G_N_ELEMENTS (drag_types_source), GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { gtk_drag_source_unset (GTK_WIDGET (self)); } if (features & EMPATHY_PERSONA_VIEW_FEATURE_PERSONA_DROP) { gtk_drag_dest_set (GTK_WIDGET (self), GTK_DEST_DEFAULT_ALL, drag_types_dest, G_N_ELEMENTS (drag_types_dest), GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { gtk_drag_dest_unset (GTK_WIDGET (self)); } g_object_notify (G_OBJECT (self), "features"); }
void timeSeriesPlotDragAndDropEnable(splotd *sp, gboolean active) { static GtkTargetEntry target = {"text/plain", GTK_TARGET_SAME_APP, 1001}; if (active) { gtk_drag_source_set(GTK_WIDGET(sp), GDK_BUTTON1_MASK, &target, 1, GDK_ACTION_COPY); g_signal_connect(G_OBJECT(sp), "drag_data_get", G_CALLBACK(start_timeSeries_drag), NULL); gtk_drag_dest_set(GTK_WIDGET(sp), GTK_DEST_DEFAULT_ALL /* DROP */, &target, 1, GDK_ACTION_COPY /*MOVE*/); g_signal_connect(G_OBJECT(sp), "drag_data_received", G_CALLBACK(receive_timeSeries_drag), NULL); } else { g_signal_handlers_disconnect_by_func(G_OBJECT(sp), G_CALLBACK(start_timeSeries_drag), NULL); g_signal_handlers_disconnect_by_func(G_OBJECT(sp), G_CALLBACK(receive_timeSeries_drag), NULL); gtk_drag_source_unset(GTK_WIDGET(sp)); gtk_drag_dest_unset(GTK_WIDGET(sp)); } }
void panel_drawer_set_dnd_enabled (Drawer *drawer, gboolean dnd_enabled) { if (dnd_enabled) { static GtkTargetEntry dnd_targets[] = { { "application/x-mate-panel-applet-internal", 0, 0 } }; gtk_widget_set_has_window (drawer->button, TRUE); gtk_drag_source_set (drawer->button, GDK_BUTTON1_MASK, dnd_targets, 1, GDK_ACTION_MOVE); //FIXME: we're forgetting the use_custom_icon case, here gtk_drag_source_set_icon_name (drawer->button, button_widget_get_icon_name (BUTTON_WIDGET (drawer->button))); gtk_widget_set_has_window (drawer->button, FALSE); } else gtk_drag_source_unset (drawer->button); }
static void set_drag_source_enabled (GcalEventWidget *self, gboolean enabled) { GtkWidget *widget = GTK_WIDGET (self); if (enabled) { /* Setup the event widget as a drag source */ gtk_drag_source_set (widget, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_MOVE); gtk_drag_source_add_text_targets (widget); } else { gtk_drag_source_unset (GTK_WIDGET (widget)); } }
static void contact_list_view_set_list_features (EmpathyContactListView *view, EmpathyContactListFeatureFlags features) { EmpathyContactListViewPriv *priv = GET_PRIV (view); gboolean has_tooltip; g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); priv->list_features = features; /* Update DnD source/dest */ if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) { gtk_drag_source_set (GTK_WIDGET (view), GDK_BUTTON1_MASK, drag_types_source, G_N_ELEMENTS (drag_types_source), GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { gtk_drag_source_unset (GTK_WIDGET (view)); } if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) { gtk_drag_dest_set (GTK_WIDGET (view), GTK_DEST_DEFAULT_ALL, drag_types_dest, G_N_ELEMENTS (drag_types_dest), GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { /* FIXME: URI could still be droped depending on FT feature */ gtk_drag_dest_unset (GTK_WIDGET (view)); } /* Update has-tooltip */ has_tooltip = (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP) != 0; gtk_widget_set_has_tooltip (GTK_WIDGET (view), has_tooltip); }
/****************************************************************************** * * Callback functions. * ******************************************************************************/ static gboolean cb_album_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) { GimvThumbView *tv = data; gint row; GimvThumb *thumb; gboolean retval = event->button == 3 ? TRUE : FALSE; g_return_val_if_fail (GIMV_IS_THUMB_VIEW (tv), retval); row = gimv_zlist_cell_index_from_xy (GIMV_ZLIST (widget), event->x, event->y); if (row < 0) { gtk_drag_source_unset (widget); g_object_set_data (G_OBJECT (widget), "drag-unset", GINT_TO_POINTER (1)); return retval; } thumb = gimv_zalbum_get_cell_data (GIMV_ZALBUM (widget), row); if (!thumb) return retval; retval = gimv_thumb_view_thumb_button_press_cb (widget, event, thumb); return retval; }
static VALUE rg_m_source_unset(VALUE self, VALUE widget) { gtk_drag_source_unset(RVAL2WIDGET(widget)); return self; }
static void gimp_view_real_set_viewable (GimpView *view, GimpViewable *old, GimpViewable *viewable) { GType viewable_type = G_TYPE_NONE; if (viewable == view->viewable) return; if (viewable) { viewable_type = G_TYPE_FROM_INSTANCE (viewable); g_return_if_fail (g_type_is_a (viewable_type, view->renderer->viewable_type)); } if (view->viewable) { g_object_remove_weak_pointer (G_OBJECT (view->viewable), (gpointer) &view->viewable); if (! viewable && ! view->renderer->is_popup) { if (gimp_dnd_viewable_source_remove (GTK_WIDGET (view), G_TYPE_FROM_INSTANCE (view->viewable))) { if (gimp_viewable_get_size (view->viewable, NULL, NULL)) gimp_dnd_pixbuf_source_remove (GTK_WIDGET (view)); gtk_drag_source_unset (GTK_WIDGET (view)); } } } else if (viewable && ! view->renderer->is_popup) { if (gimp_dnd_drag_source_set_by_type (GTK_WIDGET (view), GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, viewable_type, GDK_ACTION_COPY)) { gimp_dnd_viewable_source_add (GTK_WIDGET (view), viewable_type, gimp_view_drag_viewable, NULL); if (gimp_viewable_get_size (viewable, NULL, NULL)) gimp_dnd_pixbuf_source_add (GTK_WIDGET (view), gimp_view_drag_pixbuf, NULL); } } gimp_view_renderer_set_viewable (view->renderer, viewable); view->viewable = viewable; if (view->viewable) { g_object_add_weak_pointer (G_OBJECT (view->viewable), (gpointer) &view->viewable); } }
static void combobox_changed (GtkComboBox *combobox, PanelRunDialog *dialog) { char *text; char *start; char *msg; text = g_strdup (panel_run_dialog_get_combo_text (dialog)); start = text; while (*start != '\0' && g_ascii_isspace (*start)) start++; /* update item name to use for dnd */ if (!dialog->use_program_list) { if (dialog->desktop_path) { g_free (dialog->desktop_path); dialog->desktop_path = NULL; } if (dialog->item_name) { g_free (dialog->item_name); dialog->item_name = NULL; } } /* desensitize run button if no text entered */ if (!start || !start [0]) { g_free (text); gtk_widget_set_sensitive (dialog->run_button, FALSE); gtk_drag_source_unset (dialog->run_dialog); if (panel_profile_get_enable_program_list ()) gtk_label_set_text (GTK_LABEL (dialog->program_label), _("Select an application to view its description.")); panel_run_dialog_set_default_icon (dialog, FALSE); if (dialog->find_command_idle_id) { g_source_remove (dialog->find_command_idle_id); dialog->find_command_idle_id = 0; } if (panel_profile_get_enable_program_list ()) { GtkTreeIter iter; GtkTreePath *path; gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->program_list_store), panel_run_dialog_make_all_list_visible, NULL); path = gtk_tree_path_new_first (); if (gtk_tree_model_get_iter (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->program_list)), &iter, path)) gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (dialog->program_list), path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); } return; } gtk_widget_set_sensitive (dialog->run_button, TRUE); gtk_drag_source_set (dialog->run_dialog, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY); gtk_drag_source_add_uri_targets (dialog->run_dialog); if (panel_profile_get_enable_program_list () && !dialog->use_program_list) { msg = g_strdup_printf (_("Will run command: '%s'"), start); gtk_label_set_text (GTK_LABEL (dialog->program_label), msg); g_free (msg); } /* look up icon for the command */ if (panel_profile_get_enable_program_list () && !dialog->use_program_list && !dialog->find_command_idle_id) dialog->find_command_idle_id = g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) panel_run_dialog_find_command_idle, dialog, NULL); g_free (text); }