static GtkActionGroup * create_or_ref_display_actions (gboolean include_common) { if (display_actions) return g_object_ref (display_actions); display_actions = gtk_action_group_new ("display-actions"); gtk_action_group_set_translation_domain (display_actions, NULL); gtk_action_group_set_translate_func (display_actions, _dia_translate, NULL, NULL); if (include_common) gtk_action_group_add_actions (display_actions, common_entries, G_N_ELEMENTS (common_entries), NULL); gtk_action_group_add_actions (display_actions, display_entries, G_N_ELEMENTS (display_entries), NULL); gtk_action_group_add_toggle_actions (display_actions, display_toggle_entries, G_N_ELEMENTS (display_toggle_entries), NULL); gtk_action_group_add_radio_actions (display_actions, display_select_radio_entries, G_N_ELEMENTS (display_select_radio_entries), 0, /* SELECT_REPLACE - first radio entry */ G_CALLBACK (select_style_callback), NULL); /* the initial reference */ return display_actions; }
int clip_GTK_ACTIONGROUPSETTRANSLATEFUNC(ClipMachine * ClipMachineMemory) { C_object *cagroup = _fetch_co_arg(ClipMachineMemory); ClipVar *cfunc = _clip_spar(ClipMachineMemory, 2); ClipVar *cfunc2 = _clip_spar(ClipMachineMemory, 3); C_var *c = NEW(C_var); CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCOBJ(cagroup, GTK_IS_ACTION_GROUP(cagroup->object)); CHECKARG2(2, PCODE_type_of_ClipVarType, CCODE_type_of_ClipVarType); CHECKARG2(3, PCODE_type_of_ClipVarType, CCODE_type_of_ClipVarType); c->ClipMachineMemory = ClipMachineMemory; c->co = cagroup; _clip_mclone(ClipMachineMemory, &c->cfunc, cfunc); _clip_mclone(ClipMachineMemory, &c->cfunc2, cfunc2); gtk_action_group_set_translate_func(GTK_ACTION_GROUP(cagroup->object), (GtkTranslateFunc) translate_func, c, (GtkDestroyNotify) destroy_notify); return 0; err: return 1; }
static VALUE rg_set_translate_func(VALUE self) { VALUE func = rb_block_proc(); G_RELATIVE(self, func); gtk_action_group_set_translate_func(_SELF(self), (GtkTranslateFunc)translate_func, (gpointer)func, NULL); return self; }
/* * Initialise tool actions. * The caller owns the return value. */ static GtkActionGroup * create_or_ref_tool_actions (void) { GtkIconFactory *icon_factory; GtkActionGroup *actions; GtkAction *action; int i; if (tool_actions) return g_object_ref (tool_actions); actions = gtk_action_group_new ("tool-actions"); gtk_action_group_set_translation_domain (actions, NULL); gtk_action_group_set_translate_func (actions, _dia_translate, NULL, NULL); gtk_action_group_add_actions (actions, tool_entries, G_N_ELEMENTS (tool_entries), NULL); icon_factory = gtk_icon_factory_new (); for (i = 0; i < num_tools; i++) { action = gtk_action_group_get_action (actions, tool_data[i].action_name); if (action != NULL) { g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (tool_menu_select), &tool_data[i].callback_data); gtk_action_set_tooltip (action, _(tool_data[i].tool_desc)); { GdkPixbuf *pb = tool_get_pixbuf (&tool_data[i]); GtkIconSet *is = gtk_icon_set_new_from_pixbuf (pb); /* not sure if the action name is unique enough */ gtk_icon_factory_add (icon_factory, tool_data[i].action_name, is); gtk_action_set_stock_id (action, tool_data[i].action_name); g_object_unref (pb); } } else { g_warning ("couldn't find tool menu item %s", tool_data[i].action_name); } } gtk_icon_factory_add_default (icon_factory); return actions; }
static void _setup_global_actions (void) { if (tool_actions) return; g_return_if_fail (_ui_manager == NULL); g_return_if_fail (toolbox_actions == NULL); register_stock_icons (); /* for the toolbox menu */ toolbox_actions = gtk_action_group_new ("toolbox-actions"); gtk_action_group_set_translation_domain (toolbox_actions, NULL); gtk_action_group_set_translate_func (toolbox_actions, _dia_translate, NULL, NULL); gtk_action_group_add_actions (toolbox_actions, common_entries, G_N_ELEMENTS (common_entries), NULL); gtk_action_group_add_actions (toolbox_actions, toolbox_entries, G_N_ELEMENTS (toolbox_entries), NULL); _ui_manager = gtk_ui_manager_new (); g_signal_connect (G_OBJECT (_ui_manager), "connect_proxy", G_CALLBACK (_ui_manager_connect_proxy), NULL); g_signal_connect (G_OBJECT (_ui_manager), "pre-activate", G_CALLBACK (_action_start), NULL); g_signal_connect (G_OBJECT (_ui_manager), "post-activate", G_CALLBACK (_action_done), NULL); gtk_ui_manager_set_add_tearoffs (_ui_manager, DIA_SHOW_TEAROFFS); gtk_ui_manager_insert_action_group (_ui_manager, toolbox_actions, 0); tool_actions = create_or_ref_tool_actions (); }
/* initialize callbacks from plug-ins */ static void add_plugin_actions (GtkUIManager *ui_manager, const gchar *base_path) { GtkActionGroup *actions; GtkAction *action; GList *cblist; DiaCallbackFilter *cbf = NULL; gchar *name; guint id; static guint cnt = 0; name = g_strdup_printf ("plugin-actions-%d", cnt); actions = gtk_action_group_new (name); gtk_action_group_set_translation_domain (actions, NULL); gtk_action_group_set_translate_func (actions, _dia_translate, NULL, NULL); g_free (name); name = NULL; cnt++; gtk_ui_manager_insert_action_group (ui_manager, actions, 5 /* "back" */); g_object_unref (actions); for (cblist = filter_get_callbacks(); cblist; cblist = cblist->next) { gchar *menu_path = NULL; cbf = cblist->data; if (cbf == NULL) { g_warning ("missing DiaCallbackFilter instance"); continue; } if (cbf->action == NULL) { g_warning ("Plugin '%s': doesn't specify action. Loading failed.", cbf->description); continue; } if ( base_path != NULL && strncmp (cbf->menupath, base_path, strlen (base_path)) != 0) { /* hook for wrong base path, skip */ continue; } else if (!base_path) { /* only replace what we know */ if (strncmp (cbf->menupath, DISPLAY_MENU, strlen (DISPLAY_MENU)) == 0) menu_path = g_strdup_printf ("%s%s", INTEGRATED_MENU, cbf->menupath + strlen (DISPLAY_MENU)); else if (strncmp (cbf->menupath, TOOLBOX_MENU, strlen (TOOLBOX_MENU)) == 0) menu_path = g_strdup_printf ("%s%s", INTEGRATED_MENU, cbf->menupath + strlen (TOOLBOX_MENU)); } action = gtk_action_new (cbf->action, cbf->description, NULL, NULL); g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (plugin_callback), (gpointer) cbf); gtk_action_group_add_action (actions, action); g_object_unref (G_OBJECT (action)); id = ensure_menu_path (ui_manager, actions, menu_path ? menu_path : cbf->menupath, TRUE); gtk_ui_manager_add_ui (ui_manager, id, menu_path ? menu_path : cbf->menupath, cbf->description, cbf->action, GTK_UI_MANAGER_AUTO, FALSE); g_free (menu_path); } }
GtkUIManager *create_menu_bar(GtkWidget *window) { GtkUIManager *ifactory; #if 0 gboolean flag_emacs = FALSE; gchar *key_theme = NULL; GtkSettings *settings = gtk_settings_get_default(); if (settings) { g_object_get(settings, "gtk-key-theme-name", &key_theme, NULL); if (key_theme) { if (!g_ascii_strcasecmp(key_theme, "Emacs")) flag_emacs = TRUE; g_free(key_theme); } } #endif ifactory = gtk_ui_manager_new(); GtkActionGroup *actions = gtk_action_group_new("Actions"); gtk_action_group_set_translate_func(actions, menu_translate, NULL, NULL); gtk_action_group_add_actions(actions, menu_items, nmenu_items, NULL); gtk_action_group_add_toggle_actions (actions, toggle_entries, n_toggle_entries, NULL); gtk_ui_manager_insert_action_group(ifactory, actions, 0); g_object_unref(actions); gtk_ui_manager_add_ui_from_string(ifactory, ui_info, -1, NULL); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); /* hidden keybinds */ gtk_accel_group_connect( accel_group, GDK_W, GDK_CONTROL_MASK, 0, g_cclosure_new_swap(G_CALLBACK(on_file_close), NULL, NULL)); gtk_accel_group_connect( accel_group, GDK_T, GDK_CONTROL_MASK, 0, g_cclosure_new_swap(G_CALLBACK(on_option_always_on_top), NULL, NULL)); gtk_widget_add_accelerator( gtk_ui_manager_get_widget(ifactory, "/M/Edit/Redo"), "activate", accel_group, GDK_Y, GDK_CONTROL_MASK, 0); gtk_widget_add_accelerator( gtk_ui_manager_get_widget(ifactory, "/M/Search/FindNext"), "activate", accel_group, GDK_F3, 0, 0); gtk_widget_add_accelerator( gtk_ui_manager_get_widget(ifactory, "/M/Search/FindPrevious"), "activate", accel_group, GDK_F3, GDK_SHIFT_MASK, 0); gtk_widget_add_accelerator( gtk_ui_manager_get_widget(ifactory, "/M/Search/Replace"), "activate", accel_group, GDK_R, GDK_CONTROL_MASK, 0); /* initialize sensitivities */ gtk_widget_set_sensitive( gtk_ui_manager_get_widget(ifactory, "/M/Search/FindNext"), FALSE); gtk_widget_set_sensitive( gtk_ui_manager_get_widget(ifactory, "/M/Search/FindPrevious"), FALSE); menu_item_save = gtk_ui_manager_get_widget(ifactory, "/M/File/Save"); menu_item_cut = gtk_ui_manager_get_widget(ifactory, "/M/Edit/Cut"); menu_item_copy = gtk_ui_manager_get_widget(ifactory, "/M/Edit/Copy"); menu_item_paste = gtk_ui_manager_get_widget(ifactory, "/M/Edit/Paste"); menu_item_delete = gtk_ui_manager_get_widget(ifactory, "/M/Edit/Delete"); menu_sensitivity_from_selection_bound(FALSE); return ifactory; }
static void word_list_window_init (WordListWindow *window) { GtkWidget *word_list, *vbox, *statusbar; GtkUIManager *ui; GtkActionGroup *actions; gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window), 600, 450); gtk_window_set_title(GTK_WINDOW(window), _("Edit the dictionary")); #if GTK_CHECK_VERSION(3, 2, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else vbox = gtk_vbox_new(FALSE, 0); #endif gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); window->action_group = actions = gtk_action_group_new("Actions"); #if ENABLE_NLS gtk_action_group_set_translate_func(window->action_group, translate_func, NULL, NULL); #endif gtk_action_group_add_actions(actions, menu_action_entries, n_menu_action_entries, window); gtk_action_group_add_radio_actions(actions, dictionary_entries, n_dictionary_entries, DICT_ENUM_DICTIONARY_TYPE_ANTHY, G_CALLBACK(activate_radio_action), window); window->ui_manager = ui = gtk_ui_manager_new(); gtk_ui_manager_insert_action_group(ui, actions, 0); g_signal_connect(ui, "add_widget", G_CALLBACK(add_widget_cb), vbox); gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui)); gtk_ui_manager_add_ui_from_file(ui, UIM_DATADIR "/helperdata/uim-dict-ui.xml", NULL); gtk_ui_manager_ensure_update(ui); window->word_list = word_list = word_list_view_new(); word_list_view_set_visible_cclass_code_column(WORD_LIST_VIEW(word_list), TRUE); word_list_view_set_visible_freq_column(WORD_LIST_VIEW(word_list), TRUE); gtk_widget_show(word_list); gtk_box_pack_start(GTK_BOX(vbox), word_list, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))), "button-press-event", G_CALLBACK(word_list_button_press_cb), window); g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))), "row-activated", G_CALLBACK(word_list_row_activated_cb), window); g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))), "key-press-event", G_CALLBACK(word_list_key_press_cb), window); g_signal_connect(G_OBJECT(WORD_LIST_VIEW(window->word_list)->selection), "changed", G_CALLBACK(word_list_selection_changed_cb), window); window->statusbar = statusbar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0); gtk_widget_show(statusbar); word_list_window_set_sensitive(window); }