// // Create the navigator widget // NavGtk::NavGtk( void *nav_parent_ctx, GtkWidget *nav_parent_wid, const char *nav_name, ldh_tSesContext nav_ldhses, const char *nav_root_name, GtkWidget **w, pwr_tStatus *status ) : Nav(nav_parent_ctx,nav_name,nav_ldhses,nav_root_name,status), parent_wid(nav_parent_wid) { GtkWidget *scrolledbrow = scrolledbrowwidgetgtk_new( Nav::init_brow_cb, this, &brow_widget); form_widget = gtk_frame_new( NULL); gtk_container_add( GTK_CONTAINER(form_widget), scrolledbrow); gtk_container_set_border_width( GTK_CONTAINER(scrolledbrow), 3); selection_widget = gtk_invisible_new(); gtk_selection_add_target( selection_widget, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1); g_signal_connect( selection_widget, "selection-get", G_CALLBACK( nav_sel_convert_cb), this); sel_lose_id = g_signal_connect( selection_widget, "selection-clear-event", G_CALLBACK( nav_sel_lose_cb), this); gtk_widget_show_all( brow_widget); set_inputfocus(0); *w = form_widget; *status = 1; }
static VALUE gtkdrag_selection_add_target(VALUE self, VALUE widget, VALUE selection, VALUE target, VALUE info) { gtk_selection_add_target(RVAL2WIDGET(widget), RVAL2ATOM(selection), RVAL2ATOM(target), NUM2INT(info)); return self; }
void wxClipboard::AddSupportedTarget(GdkAtom atom) { gtk_selection_add_target ( m_clipboardWidget, GTKGetClipboardAtom(), atom, 0 // info (same as client data) unused ); }
int appDocOwnSelection( EditDocument * ed, const char * selection, AppSelectionTargetType * targets, int targetCount ) { int i; AppSelectionType * ast; EditApplication * ea= ed->edApplication; ast= ea->eaDocSelectionTypes; for ( i= 0; i < ea->eaDocSelectionTypeCount; ast++, i++ ) { if ( ! strcmp( ast->astSelectionString, selection ) ) { break; } } if ( i >= ea->eaDocSelectionTypeCount ) { SDEB(selection); return -1; } if ( ast->astTargetTypeCount == 0 ) { SLDEB(selection,ast->astTargetTypeCount); return -1; } for ( i= 0; i < targetCount; i++ ) { if ( ! targets[i].asttTargetAtom ) { targets[i].asttTargetAtom= gdk_atom_intern( targets[i].asttTargetString, 0 ); if ( ! targets[i].asttTargetAtom ) { SDEB(targets[i].asttTargetString); XDEB(targets[i].asttTargetAtom); return -1; } } gtk_selection_add_target( ed->edDocumentWidget, ast->astSelectionAtom, targets[i].asttTargetAtom, 0 ); } ed->edTargetTypes= targets; ed->edTargetTypeCount= targetCount; if ( ! gtk_selection_owner_set( ed->edDocumentWidget, ast->astSelectionAtom, GDK_CURRENT_TIME ) ) { return -1; } return 0; }
int main( int argc, char *argv[] ) { GtkWidget *window; static int have_selection = FALSE; gtk_init (&argc, &argv); /* Create the toplevel window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Event Box"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect (window, "destroy", G_CALLBACK (exit), NULL); /* Create a toggle button to act as the selection */ selection_widget = gtk_invisible_new (); selection_button = gtk_toggle_button_new_with_label ("Claim Selection"); gtk_container_add (GTK_CONTAINER (window), selection_button); gtk_widget_show (selection_button); g_signal_connect (selection_button, "toggled", G_CALLBACK (selection_toggled), (gpointer) &have_selection); g_signal_connect (selection_widget, "selection_clear_event", G_CALLBACK (selection_clear), (gpointer) &have_selection); gtk_selection_add_target (selection_widget, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1); g_signal_connect (selection_widget, "selection_get", G_CALLBACK (selection_handle), (gpointer) &have_selection); gtk_widget_show (selection_button); gtk_widget_show (window); gtk_main (); return 0; }
bool wxClipboard::AddData( wxDataObject *data ) { wxCHECK_MSG( m_open, false, wxT("clipboard not open") ); wxCHECK_MSG( data, false, wxT("data is invalid") ); // we can only store one wxDataObject Clear(); m_data = data; // get formats from wxDataObjects wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ]; m_data->GetAllFormats( array ); // primary selection or clipboard GdkAtom clipboard = m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY : g_clipboardAtom; // by default provide TIMESTAMP as a target gtk_selection_add_target( GTK_WIDGET(m_clipboardWidget), clipboard, g_timestampAtom, 0 ); for (size_t i = 0; i < m_data->GetFormatCount(); i++) { wxLogTrace( TRACE_CLIPBOARD, wxT("wxClipboard now supports atom %s"), array[i].GetId().c_str() ); // printf( "added %s\n", // gdk_atom_name( array[i].GetFormatId() ) ); gtk_selection_add_target( GTK_WIDGET(m_clipboardWidget), clipboard, array[i], 0 ); /* what is info ? */ } delete[] array; gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), "selection_get", GTK_SIGNAL_FUNC(selection_handler), GUINT_TO_POINTER( gdk_event_get_time(gtk_get_current_event()) ) ); #if wxUSE_THREADS /* disable GUI threads */ #endif /* Tell the world we offer clipboard data */ bool res = (gtk_selection_owner_set( m_clipboardWidget, clipboard, (guint32) GDK_CURRENT_TIME )); if (m_usePrimary) m_ownsPrimarySelection = res; else m_ownsClipboard = res; #if wxUSE_THREADS /* re-enable GUI threads */ #endif return res; }
gboolean gwy_remote_open_files(GwyRemote *remote, int argc, char **argv) { GdkNativeWindow xid; GdkDragContext *context; GdkDragProtocol protocol; GtkWidget *source; GdkAtom sel_type, sel_id; GString *file_list; GList *targetlist; gchar *cwd; gint i; if (!remote) return FALSE; xid = gdk_drag_get_protocol_for_display(remote->display, remote->winid, &protocol); /* FIXME: Here we may need some platform-dependent protocol check. * protocol should be GDK_DRAG_PROTO_XDND on X11, but on win32 * gdk_drag_get_protocol_for_display returns 0, which means there * is no DnD support for target window. */ if (!xid) { g_printerr("Gwyddion window doesn't support DnD.\n"); return FALSE; } /* Now we have the toolbox, it seems to support DnD and we have some files * to send to it. So build the list. */ cwd = g_get_current_dir(); file_list = g_string_sized_new(32*argc); for (i = 0; i < argc; i++) { gchar *s, *t; if (i) g_string_append_c(file_list, '\n'); if (g_path_is_absolute(argv[i])) s = g_filename_to_uri(argv[i], NULL, NULL); else { t = g_build_filename(cwd, argv[i], NULL); s = g_filename_to_uri(t, NULL, NULL); g_free(t); } g_string_append(file_list, s); g_free(s); } /* Don't hang when the toolbox is non-responsive. * This may not be necessary in Gwyddion, but it does not hurt either. */ g_timeout_add(2000, toolbox_timeout, NULL); /* Set up an DnD-source. */ source = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(source, "selection-get", G_CALLBACK(source_selection_get), file_list->str); gtk_widget_realize(source); /* Specify the id and the content-type of the selection used to * pass the URIs to Gwyddion toolbox. */ sel_id = gdk_atom_intern("XdndSelection", FALSE); sel_type = gdk_atom_intern("text/plain", FALSE); targetlist = g_list_prepend(NULL, GUINT_TO_POINTER(sel_type)); /* Assign the selection to our DnD-source. */ gtk_selection_owner_set(source, sel_id, GDK_CURRENT_TIME); gtk_selection_add_target(source, sel_id, sel_type, 0); /* Drag_begin/motion/drop. */ context = gdk_drag_begin(source->window, targetlist); gdk_drag_motion(context, remote->toolbox, protocol, 0, 0, GDK_ACTION_COPY, GDK_ACTION_COPY, GDK_CURRENT_TIME); gdk_drag_drop(context, GDK_CURRENT_TIME); /* Finally enter the mainloop to handle the events. */ gtk_main(); gdk_notify_startup_complete(); return TRUE; }
bool wxClipboard::AddData( wxDataObject *data ) { #if wxUSE_NANOX return false; #else wxCHECK_MSG( m_open, false, wxT("clipboard not open") ); wxCHECK_MSG( data, false, wxT("data is invalid") ); /* we can only store one wxDataObject */ Clear(); m_data = data; /* get formats from wxDataObjects */ wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ]; m_data->GetAllFormats( array ); #if 0 /* primary selection or clipboard */ Atom clipboard = m_usePrimary ? (Atom) 1 // 1 = primary selection : g_clipboardAtom; #endif // 0 for (size_t i = 0; i < m_data->GetFormatCount(); i++) { wxLogTrace( TRACE_CLIPBOARD, wxT("wxClipboard now supports atom %s"), array[i].GetId().c_str() ); #if 0 gtk_selection_add_target( GTK_WIDGET(m_clipboardWidget), clipboard, array[i], 0 ); /* what is info ? */ #endif } delete[] array; #if 0 gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), "selection_get", GTK_SIGNAL_FUNC(selection_handler), (gpointer) NULL ); #endif #if wxUSE_THREADS /* disable GUI threads */ #endif bool res = false; #if 0 /* Tell the world we offer clipboard data */ res = (gtk_selection_owner_set( m_clipboardWidget, clipboard, (guint32) GDK_CURRENT_TIME )); #endif if (m_usePrimary) m_ownsPrimarySelection = res; else m_ownsClipboard = res; #if wxUSE_THREADS /* re-enable GUI threads */ #endif return res; #endif }
static gboolean charpicker_applet_fill (MatePanelApplet *applet) { MatePanelAppletOrient orientation; charpick_data *curr_data; GdkAtom utf8_atom; GList *list; gchar *string; GtkActionGroup *action_group; gchar *ui_path; g_set_application_name (_("Character Palette")); gtk_window_set_default_icon_name ("accessories-character-map"); mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet)); mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); curr_data = g_new0 (charpick_data, 1); curr_data->last_index = NO_LAST_INDEX; curr_data->applet = GTK_WIDGET (applet); curr_data->about_dialog = NULL; curr_data->add_edit_dialog = NULL; curr_data->settings = mate_panel_applet_settings_new (applet, "org.mate.panel.applet.charpick"); get_chartable (curr_data); string = g_settings_get_string (curr_data->settings, "current-list"); if (string) { list = curr_data->chartable; while (list) { if (g_ascii_strcasecmp (list->data, string) == 0) curr_data->charlist = list->data; list = g_list_next (list); } /* FIXME: yeah leak, but this code is full of leaks and evil point shuffling. This should really be rewritten -George */ if (curr_data->charlist == NULL) curr_data->charlist = string; else g_free (string); } else { curr_data->charlist = curr_data->chartable->data; } curr_data->panel_size = mate_panel_applet_get_size (applet); orientation = mate_panel_applet_get_orient (applet); curr_data->panel_vertical = (orientation == MATE_PANEL_APPLET_ORIENT_LEFT) || (orientation == MATE_PANEL_APPLET_ORIENT_RIGHT); build_table (curr_data); g_signal_connect (G_OBJECT (curr_data->applet), "key_press_event", G_CALLBACK (key_press_event), curr_data); utf8_atom = gdk_atom_intern ("UTF8_STRING", FALSE); gtk_selection_add_target (curr_data->applet, GDK_SELECTION_PRIMARY, utf8_atom, 0); gtk_selection_add_target (curr_data->applet, GDK_SELECTION_CLIPBOARD, utf8_atom, 0); g_signal_connect (G_OBJECT (curr_data->applet), "selection_get", G_CALLBACK (charpick_selection_handler), curr_data); g_signal_connect (G_OBJECT (curr_data->applet), "selection_clear_event", G_CALLBACK (selection_clear_cb), curr_data); make_applet_accessible (GTK_WIDGET (applet)); /* session save signal */ g_signal_connect (G_OBJECT (applet), "change_orient", G_CALLBACK (applet_change_orient), curr_data); g_signal_connect (G_OBJECT (applet), "size_allocate", G_CALLBACK (applet_size_allocate), curr_data); g_signal_connect (G_OBJECT (applet), "destroy", G_CALLBACK (applet_destroy), curr_data); gtk_widget_show_all (GTK_WIDGET (applet)); action_group = gtk_action_group_new ("Charpicker Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, charpick_applet_menu_actions, G_N_ELEMENTS (charpick_applet_menu_actions), curr_data); ui_path = g_build_filename (CHARPICK_MENU_UI_DIR, "charpick-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet), ui_path, action_group); g_free (ui_path); if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) { GtkAction *action; action = gtk_action_group_get_action (action_group, "Preferences"); gtk_action_set_visible (action, FALSE); } g_object_unref (action_group); register_stock_for_edit (); populate_menu (curr_data); return TRUE; }
void nsClipboard::AddTarget(GdkAtom aName, GdkAtom aClipboard) { gtk_selection_add_target(mWidget, aClipboard, aName, 0); }
gboolean gimp_remote_drop_files (GdkDisplay *display, GdkWindow *window, GString *file_list) { GdkDragContext *context; GdkDragProtocol protocol; GtkWidget *source; GdkAtom sel_type; GdkAtom sel_id; GList *targetlist; guint timeout; gdk_drag_get_protocol_for_display (display, GDK_WINDOW_XID (window), &protocol); if (protocol != GDK_DRAG_PROTO_XDND) { g_printerr ("GIMP Window doesnt use Xdnd-Protocol - huh?\n"); return FALSE; } /* Problem: If the Toolbox is hidden via Tab (gtk_widget_hide) * it does not accept DnD-Operations and gtk_main() will not be * terminated. If the Toolbox is simply unmapped (by the WM) * DnD works. But in both cases gdk_window_is_visible() returns * FALSE. To work around this we add a timeout and abort after * 5 seconds. */ timeout = g_timeout_add (5000, toolbox_hidden, NULL); /* set up an DND-source */ source = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (source, "selection-get", G_CALLBACK (source_selection_get), file_list->str); gtk_widget_realize (source); /* specify the id and the content-type of the selection used to * pass the URIs to GIMP. */ sel_id = gdk_atom_intern ("XdndSelection", FALSE); sel_type = gdk_atom_intern ("text/uri-list", FALSE); targetlist = g_list_prepend (NULL, GUINT_TO_POINTER (sel_type)); /* assign the selection to our DnD-source */ gtk_selection_owner_set (source, sel_id, GDK_CURRENT_TIME); gtk_selection_add_target (source, sel_id, sel_type, 0); /* drag_begin/motion/drop */ context = gdk_drag_begin (gtk_widget_get_window (source), targetlist); gdk_drag_motion (context, window, protocol, 0, 0, GDK_ACTION_COPY, GDK_ACTION_COPY, GDK_CURRENT_TIME); gdk_drag_drop (context, GDK_CURRENT_TIME); /* finally enter the mainloop to handle the events */ gtk_main (); g_source_remove (timeout); return TRUE; }