Пример #1
0
static gboolean
gdict_applet_factory (MatePanelApplet *applet,
                      const gchar *iid,
		      gpointer     data)
{
  gboolean retval = FALSE;
  gchar *ui_path;
  GdictApplet *dictionary_applet = GDICT_APPLET (applet);
  GdictAppletPrivate *priv = dictionary_applet->priv;

  if (((!strcmp (iid, "DictionaryApplet"))) && gdict_create_data_dir ())
    {
      /* Set up the menu */
      priv->context_menu_action_group = gtk_action_group_new ("Dictionary Applet Actions");
      gtk_action_group_set_translation_domain(priv->context_menu_action_group,
                                              GETTEXT_PACKAGE);
      gtk_action_group_add_actions(priv->context_menu_action_group,
								gdict_applet_menu_actions,
								G_N_ELEMENTS (gdict_applet_menu_actions),
								applet);
      ui_path = g_build_filename(PKGDATADIR, "dictionary-applet-menu.xml", NULL);
      mate_panel_applet_setup_menu_from_file (applet, ui_path,
                                              priv->context_menu_action_group);
      g_free (ui_path);

      gtk_widget_show (GTK_WIDGET (applet));

      /* set the menu items insensitive */
      gdict_applet_set_menu_items_sensitive (dictionary_applet, FALSE);
      
      retval = TRUE;
    }

  return retval;
}
Пример #2
0
static void
eog_reload_plugin_activate (EogWindowActivatable *activatable)
{
	GtkUIManager *manager;
	EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable);

	eog_debug (DEBUG_PLUGINS);

	manager = eog_window_get_ui_manager (plugin->window);

	plugin->ui_action_group = gtk_action_group_new ("EogReloadPluginActions");

	gtk_action_group_set_translation_domain (plugin->ui_action_group,
						 GETTEXT_PACKAGE);

	gtk_action_group_add_actions (plugin->ui_action_group,
				      action_entries,
				      G_N_ELEMENTS (action_entries),
				      plugin->window);

	gtk_ui_manager_insert_action_group (manager,
					    plugin->ui_action_group,
					    -1);

	plugin->ui_id = gtk_ui_manager_add_ui_from_string (manager,
							   ui_definition,
							   -1, NULL);
	g_warn_if_fail (plugin->ui_id != 0);
}
Пример #3
0
void
edit_metadata__gth_browser_construct_cb (GthBrowser *browser)
{
	BrowserData *data;
	GError      *error = NULL;

	g_return_if_fail (GTH_IS_BROWSER (browser));

	data = g_new0 (BrowserData, 1);
	data->browser = browser;

	data->actions = gtk_action_group_new ("Edit Metadata Actions");
	gtk_action_group_set_translation_domain (data->actions, NULL);
	gtk_action_group_add_actions (data->actions,
				      edit_metadata_action_entries,
				      G_N_ELEMENTS (edit_metadata_action_entries),
				      browser);
	gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->actions, 0);

	if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) {
		g_message ("building menus failed: %s", error->message);
		g_error_free (error);
	}

	gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/Fullscreen_ToolBar/Edit_Actions/Edit_Metadata")), TRUE);

	g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
}
Пример #4
0
GtkWidget *toolbar_init(GtkWindow *parent)
{
	GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
	GtkToolbar *toolbar;
	GtkActionGroup *ag = gtk_action_group_new("Actions");
	gtk_action_group_add_actions(ag, action_items,
					G_N_ELEMENTS(action_items), parent);
	gtk_action_group_add_toggle_actions(ag, toggle_items,
					G_N_ELEMENTS(toggle_items), parent);

	GtkUIManager *ui = gtk_ui_manager_new();
	g_object_set_data(G_OBJECT(parent), "ui_manager", ui);
	gtk_ui_manager_insert_action_group(ui, ag, 0);
	GtkAccelGroup *accel = gtk_ui_manager_get_accel_group(ui);
	gtk_window_add_accel_group(parent, accel);

	GError *error = NULL;
        if (!gtk_ui_manager_add_ui_from_string (ui, ui_xml, -1, &error)) {
                g_message ("building menus failed: %s", error->message);
                g_error_free (error);
                exit (-1);
        }

	GtkWidget *menubar = gtk_ui_manager_get_widget(ui, "/menubar");
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menubar), FALSE, TRUE, 0);
	toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget(ui, "/toolbar"));
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(toolbar), FALSE, TRUE, 0);

	/* Device selection GtkComboBox */
	GtkToolItem *toolitem = gtk_tool_item_new();
	GtkWidget *dev = dev_select_combo_box_new(parent);

	gtk_container_add(GTK_CONTAINER(toolitem), dev);
	gtk_toolbar_insert(toolbar, toolitem, 0);

	/* Time/Samples entry */
	toolitem = gtk_tool_item_new();
	GtkWidget *timesamples = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(timesamples), "100");
	gtk_entry_set_alignment(GTK_ENTRY(timesamples), 1.0);
	gtk_widget_set_size_request(timesamples, 100, -1);
	gtk_container_add(GTK_CONTAINER(toolitem), timesamples);
	gtk_toolbar_insert(toolbar, toolitem, 7);

	/* Time unit combo box */
	toolitem = gtk_tool_item_new();
	GtkWidget *timeunit = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "samples");
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "ms");
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "s");
	gtk_combo_box_set_active(GTK_COMBO_BOX(timeunit), 0);
	gtk_container_add(GTK_CONTAINER(toolitem), timeunit);
	gtk_toolbar_insert(toolbar, toolitem, 8);

	g_object_set_data(G_OBJECT(parent), "timesamples", timesamples);
	g_object_set_data(G_OBJECT(parent), "timeunit", timeunit);

	return GTK_WIDGET(vbox);
}
Пример #5
0
static gboolean
geyes_applet_fill (MatePanelApplet *applet)
{
	EyesApplet *eyes_applet;
	GtkActionGroup *action_group;
	gchar *ui_path;

	g_set_application_name (_("Eyes"));
	
	gtk_window_set_default_icon_name ("mate-eyes-applet");
	mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
	mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
	
        eyes_applet = create_eyes (applet);

        eyes_applet->timeout_id = g_timeout_add (
		UPDATE_TIMEOUT, (GSourceFunc) timer_cb, eyes_applet);

	action_group = gtk_action_group_new ("Geyes Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group,
				      geyes_applet_menu_actions,
				      G_N_ELEMENTS (geyes_applet_menu_actions),
				      eyes_applet);
	ui_path = g_build_filename (GEYES_MENU_UI_DIR, "geyes-applet-menu.xml", NULL);
	mate_panel_applet_setup_menu_from_file (eyes_applet->applet,
					   ui_path, action_group);
	g_free (ui_path);

	if (mate_panel_applet_get_locked_down (eyes_applet->applet)) {
		GtkAction *action;

		action = gtk_action_group_get_action (action_group, "Props");
		gtk_action_set_visible (action, FALSE);
	}
	g_object_unref (action_group);

	gtk_widget_set_tooltip_text (GTK_WIDGET (eyes_applet->applet), _("Eyes"));

	set_atk_name_description (GTK_WIDGET (eyes_applet->applet), _("Eyes"), 
			_("The eyes look in the direction of the mouse pointer"));

	g_signal_connect (eyes_applet->vbox,
			  "dispose",
			  G_CALLBACK (dispose_cb),
			  eyes_applet);

	gtk_widget_show_all (GTK_WIDGET (eyes_applet->applet));

	/* setup here and not in create eyes so the destroy signal is set so 
	 * that when there is an error within loading the theme
	 * we can emit this signal */
        if (properties_load (eyes_applet) == FALSE)
		return FALSE;

	setup_eyes (eyes_applet);

	return TRUE;
}
Пример #6
0
/** Create a new gnc embedded window plugin. */
GncEmbeddedWindow *
gnc_embedded_window_new (const gchar *action_group_name,
                         GtkActionEntry *action_entries,
                         gint n_action_entries,
                         const gchar *ui_filename,
                         GtkWidget *enclosing_win,
                         gboolean add_accelerators,
                         gpointer user_data)
{
    GncEmbeddedWindowPrivate *priv;
    GncEmbeddedWindow *window;
    gchar *ui_fullname;
    GError *error = NULL;
    guint merge_id;

    ENTER("group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p",
          action_group_name, action_entries, n_action_entries, ui_filename,
          enclosing_win, add_accelerators, user_data);
    window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL);
    priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);

    /* Determine the full pathname of the ui file */
    ui_fullname = gnc_filepath_locate_ui_file (ui_filename);
    g_return_val_if_fail (ui_fullname != NULL, NULL);

    priv->parent_window = enclosing_win;

    /* Create menu and toolbar information */
    priv->action_group = gtk_action_group_new (action_group_name);
    gnc_gtk_action_group_set_translation_domain(priv->action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions (priv->action_group, action_entries,
                                  n_action_entries, user_data);
    gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0);
    merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, ui_fullname,
               &error);

    /* Error checking */
    g_assert(merge_id || error);
    if (error)
    {
        g_critical("Failed to load ui file.\n  Filename %s\n  Error %s",
                   ui_fullname, error->message);
        g_error_free(error);
        g_free(ui_fullname);
        LEAVE("window %p", window);
        return window;
    }

    /* Add accelerators (if wanted) */
    if (add_accelerators)
        gtk_window_add_accel_group (GTK_WINDOW(enclosing_win),
                                    gtk_ui_manager_get_accel_group(window->ui_merge));

    gtk_ui_manager_ensure_update (window->ui_merge);
    g_free(ui_fullname);
    LEAVE("window %p", window);
    return window;
}
Пример #7
0
static GtkUIManager *
remap_ui_manager_new (GtkWidget    *window,
                      GtkListStore *store)
{
  static const GtkActionEntry actions[] =
  {
    {
      "sort-hue", NULL, N_("Sort on Hue"), NULL, NULL,
      G_CALLBACK (remap_sort_callback)
    },
    {
      "sort-sat", NULL, N_("Sort on Saturation"), NULL, NULL,
      G_CALLBACK (remap_sort_callback)
    },
    {
      "sort-val", NULL, N_("Sort on Value"), NULL, NULL,
      G_CALLBACK (remap_sort_callback)
    },
    {
      "reverse", NULL, N_("Reverse Order"), NULL, NULL,
      G_CALLBACK (remap_reverse_callback)
    },
    {
      "reset", GIMP_STOCK_RESET, N_("Reset Order"), NULL, NULL,
      G_CALLBACK (remap_reset_callback)
    },
  };

  GtkUIManager   *ui_manager = gtk_ui_manager_new ();
  GtkActionGroup *group      = gtk_action_group_new ("Actions");
  GError         *error      = NULL;

  gtk_action_group_set_translation_domain (group, NULL);
  gtk_action_group_add_actions (group, actions, G_N_ELEMENTS (actions), store);

  gtk_ui_manager_insert_action_group (ui_manager, group, -1);
  g_object_unref (group);

  gtk_ui_manager_add_ui_from_string (ui_manager,
                                     "<ui>"
                                     "  <popup name=\"remap-popup\">"
                                     "    <menuitem action=\"sort-hue\" />"
                                     "    <menuitem action=\"sort-sat\" />"
                                     "    <menuitem action=\"sort-val\" />"
                                     "    <separator />"
                                     "    <menuitem action=\"reverse\" />"
                                     "    <menuitem action=\"reset\" />"
                                     "  </popup>"
                                     "</ui>",
                                     -1, &error);
  if (error)
    {
      g_warning ("error parsing ui: %s", error->message);
      g_clear_error (&error);
    }

  return ui_manager;
}
Пример #8
0
/** \brief Create menubar.
 *  \param window The main application window.
 *  \return The menubar widget.
 *
 * This function creates and initializes the main menubar for gpredict.
 * It should be called from the main gui_create function.
 */
GtkWidget *menubar_create(GtkWidget * window)
{
    GtkWidget *menubar;
    GtkActionGroup *actgrp;
    GtkUIManager *uimgr;
    GtkAccelGroup *accgrp;
    GError *error = NULL;

    //GtkWidget      *menuitem;
    //GtkWidget      *image;
    //gchar          *icon;
    guint i;


    /* create action group */
    actgrp = gtk_action_group_new("MenuActions");
    /* i18n */
    for (i = 0; i < G_N_ELEMENTS(entries); i++)
    {
        if (entries[i].label)
            entries[i].label = _(entries[i].label);
        if (entries[i].tooltip)
            entries[i].tooltip = _(entries[i].tooltip);
    }

    gtk_action_group_add_actions(actgrp, entries, G_N_ELEMENTS(entries), NULL);

    /* create UI manager */
    uimgr = gtk_ui_manager_new();
    gtk_ui_manager_insert_action_group(uimgr, actgrp, 0);

    /* accelerator group */
    accgrp = gtk_ui_manager_get_accel_group(uimgr);
    gtk_window_add_accel_group(GTK_WINDOW(window), accgrp);

    /* try to create UI from XML */
    if (!gtk_ui_manager_add_ui_from_string(uimgr, menu_desc, -1, &error))
    {
        g_print(_("Failed to build menubar: %s"), error->message);
        g_error_free(error);

        return NULL;
    }

    /* load custom icons */
    /*    icon = icon_file_name ("gpredict-shuttle-small.png");
        image = gtk_image_new_from_file (icon);
        g_free (icon);
        menuitem = gtk_ui_manager_get_widget (uimgr, "/GpredictMenu/ToolsMenu/SatLab");
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);*/

    /* now, finally, get the menubar */
    menubar = gtk_ui_manager_get_widget(uimgr, "/GpredictMenu");

    return menubar;
}
Пример #9
0
static VALUE
actiongroup_add_actions(VALUE self, VALUE entries)
{
    guint i;
    VALUE action_procs;
    guint n_entries = (guint)RARRAY_LEN(entries);
    GtkActionEntry* gentries = g_new0(GtkActionEntry, n_entries);

    if (rb_ivar_defined(self, id_action_procs) == Qtrue){
        action_procs = rb_ivar_get(self, id_action_procs);
    } else {
        action_procs = rb_hash_new();
    }

    for (i = 0; i < n_entries; i++){
        VALUE entry;
        int size;

	entry = RARRAY_PTR(entries)[i];
	size = RARRAY_LEN(entry);
        if (size < 1)
            rb_raise(rb_eArgError, "wrong array parameter");

        gentries[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
        gentries[i].callback = G_CALLBACK(activate_action);

        if (size < 2) continue;

        if (NIL_P(RARRAY_PTR(entry)[1])){
            gentries[i].stock_id = NULL;
        } else if (SYMBOL_P(RARRAY_PTR(entry)[1])){
            gentries[i].stock_id = rb_id2name(SYM2ID(RARRAY_PTR(entry)[1]));
        } else if (TYPE(RARRAY_PTR(entry)[1]) == T_STRING){
            gentries[i].stock_id = RVAL2CSTR(RARRAY_PTR(entry)[1]);
        } else{
            rb_raise(rb_eArgError,
		     "invalid argument %s (expect Symbol or String)",
                     rb_class2name(CLASS_OF(RARRAY_PTR(entry)[1])));
        }

        if (size < 3) continue;
        gentries[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
        if (size < 4) continue;
        gentries[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
        if (size < 4) continue;
        gentries[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
        if (size < 5) continue;
        rb_hash_aset(action_procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
    }
    rb_ivar_set(self, id_action_procs, action_procs);
    gtk_action_group_add_actions(_SELF(self), gentries, n_entries,
				 (gpointer)self);
    g_free(gentries);

    return self;
}
Пример #10
0
void
seahorse_pkcs11_generate_register (void)
{
	GtkActionGroup *actions;

	actions = gtk_action_group_new ("pkcs11-generate");
	gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (actions, ACTION_ENTRIES, G_N_ELEMENTS (ACTION_ENTRIES), NULL);
	seahorse_registry_register_object (G_OBJECT (actions), "generator");
}
Пример #11
0
static void
seahorse_gpgme_key_actions_init (SeahorseGpgmeKeyActions *self)
{
#ifdef WITH_KEYSERVER
	GtkActionGroup *actions = GTK_ACTION_GROUP (self);
	gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (actions, SYNC_ACTIONS,
	                              G_N_ELEMENTS (SYNC_ACTIONS), NULL);
#endif
}
Пример #12
0
static gboolean
applet_factory (MatePanelApplet *applet,
		const char  *iid,
		gpointer     user_data)
{
    gboolean ret = FALSE;
    GtkWidget *drive_list;
    AtkObject *ao;
    GtkActionGroup *action_group;
    gchar *ui_path;

    if (!strcmp (iid, drivemount_iid)) {
	g_set_application_name (_("Disk Mounter"));

	gtk_window_set_default_icon_name ("media-floppy");

	mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
	mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));

	drive_list = drive_list_new ();
	gtk_container_add (GTK_CONTAINER (applet), drive_list);

	g_signal_connect_object (applet, "change_orient",
				 G_CALLBACK (change_orient), drive_list, 0);
	g_signal_connect_object (applet, "size_allocate",
				 G_CALLBACK (size_allocate), drive_list, 0);
	g_signal_connect (applet, "change_background",
			  G_CALLBACK (change_background), drive_list);

	/* set initial state */
	change_orient (applet,
		       mate_panel_applet_get_orient (applet),
		       DRIVE_LIST (drive_list));

	action_group = gtk_action_group_new ("DriveMount Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group,
				      applet_menu_actions,
				      G_N_ELEMENTS (applet_menu_actions),
				      drive_list);
	ui_path = g_build_filename (DRIVEMOUNT_MENU_UI_DIR, "drivemount-applet-menu.xml", NULL);
	mate_panel_applet_setup_menu_from_file (applet, ui_path, action_group);
	g_free (ui_path);
	g_object_unref (action_group);

	ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
	atk_object_set_name (ao, _("Disk Mounter"));

	gtk_widget_show_all (GTK_WIDGET (applet));

	ret = TRUE;
    }

    return ret;
}
Пример #13
0
static void
gs_window_build_ui (GsWindow *window)
{
	GtkWidget *menubar;

	g_return_if_fail (GS_IS_WINDOW (window));

	window->priv->box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (window), window->priv->box);
	gtk_widget_show (window->priv->box);

	window->priv->ui_manager = gtk_ui_manager_new ();

	window->priv->ui_actions = gtk_action_group_new ("MenuActions");
	gtk_action_group_add_actions (window->priv->ui_actions,
				      action_entries,
				      G_N_ELEMENTS (action_entries),
				      window);
	gtk_action_group_add_toggle_actions (window->priv->ui_actions,
					     toggle_action_entries,
					     G_N_ELEMENTS (toggle_action_entries),
					     window);
	gtk_ui_manager_insert_action_group (window->priv->ui_manager, window->priv->ui_actions, 0);

	if (!gtk_ui_manager_add_ui_from_string (window->priv->ui_manager, UI_DEFINITION, -1, NULL)) {
		g_assert ("No se pudo cargar la UI");
	}

	menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu");
	g_assert (GTK_IS_WIDGET (menubar));
	gtk_box_pack_start (GTK_BOX (window->priv->box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);

	gtk_window_add_accel_group (GTK_WINDOW (window),
				    gtk_ui_manager_get_accel_group (window->priv->ui_manager));

	window->priv->graph = gs_graph_new ();
	gtk_widget_show (window->priv->graph);

	window->priv->hpaned = gtk_hpaned_new ();
	gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->graph, TRUE, FALSE);

	window->priv->plot_list_panel = gs_plot_list_panel_new (GS_WINDOW (window));
	gtk_paned_pack2 (GTK_PANED (window->priv->hpaned), window->priv->plot_list_panel, TRUE, FALSE);
	gtk_widget_show (window->priv->plot_list_panel);
	gtk_widget_show (window->priv->hpaned);

	gtk_box_pack_start (GTK_BOX (window->priv->box), window->priv->hpaned, TRUE, TRUE, 0);

	window->priv->statusbar = gtk_statusbar_new ();
	gtk_box_pack_end (GTK_BOX (window->priv->box), window->priv->statusbar, FALSE, FALSE, 0);
	gtk_widget_show (window->priv->statusbar);

}
/**
 * nautilus_window_initialize_menus
 * 
 * Create and install the set of menus for this window.
 * @window: A recently-created NautilusWindow.
 */
void 
nautilus_window_initialize_menus (NautilusWindow *window)
{
	GtkActionGroup *action_group;
	GtkUIManager *ui_manager;
	GtkAction *action;
	const char *ui;
	
	action_group = gtk_action_group_new ("ShellActions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	window->details->main_action_group = action_group;
	gtk_action_group_add_actions (action_group, 
				      main_entries, G_N_ELEMENTS (main_entries),
				      window);
	gtk_action_group_add_toggle_actions (action_group, 
					     main_toggle_entries, G_N_ELEMENTS (main_toggle_entries),
					     window);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
	g_object_set (action, "short_label", _("_Up"), NULL);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_HOME);
	g_object_set (action, "short_label", _("_Home"), NULL);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SHOW_HIDDEN_FILES);
	g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window);
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
				      eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
	g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window);


	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
						  show_hidden_files_preference_callback,
						  window, G_OBJECT (window));

	window->details->ui_manager = gtk_ui_manager_new ();
	ui_manager = window->details->ui_manager;
	gtk_window_add_accel_group (GTK_WINDOW (window),
				    gtk_ui_manager_get_accel_group (ui_manager));
	
	g_signal_connect (ui_manager, "connect_proxy",
			  G_CALLBACK (connect_proxy_cb), window);
	g_signal_connect (ui_manager, "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb), window);
	
	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
	g_object_unref (action_group); /* owned by ui manager */

	ui = nautilus_ui_string_get ("nautilus-shell-ui.xml");
	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);

	nautilus_window_initialize_trash_icon_monitor (window);
	nautilus_window_initialize_bookmarks_menu (window);
}
Пример #15
0
static void
setup_actions (EMailReader *reader,
               GtkUIManager *ui_manager)
{
	GtkActionGroup *action_group;
	const gchar *domain = GETTEXT_PACKAGE;

	action_group = gtk_action_group_new ("mail-convert-any");
	gtk_action_group_set_translation_domain (action_group, domain);
	gtk_action_group_add_actions (
		action_group, multi_selection_entries,
		G_N_ELEMENTS (multi_selection_entries), reader);
	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
	g_object_unref (action_group);

	/* GtkUIManager now owns the action group reference.
	 * The signal we're connecting to will only be emitted
	 * during the GtkUIManager's lifetime, so the action
	 * group will not disappear on us. */

	g_signal_connect (
		reader, "update-actions",
		G_CALLBACK (update_actions_any_cb), action_group);

	action_group = gtk_action_group_new ("mail-convert-one");
	gtk_action_group_set_translation_domain (action_group, domain);
	gtk_action_group_add_actions (
		action_group, single_selection_entries,
		G_N_ELEMENTS (single_selection_entries), reader);
	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
	g_object_unref (action_group);

	/* GtkUIManager now owns the action group reference.
	 * The signal we're connecting to will only be emitted
	 * during the GtkUIManager's lifetime, so the action
	 * group will not disappear on us. */

	g_signal_connect (
		reader, "update-actions",
		G_CALLBACK (update_actions_one_cb), action_group);
}
Пример #16
0
void sheet_item_add_menu (SheetItem *item, const char *menu, const GtkActionEntry *action_entries,
                          int nb_entries)
{
	GError *error = NULL;

	gtk_action_group_add_actions (item->priv->action_group, action_entries, nb_entries, NULL);

	if (!gtk_ui_manager_add_ui_from_string (item->priv->ui_manager, menu, -1, &error)) {
		g_message ("building menus failed: %s", error->message);
		g_error_free (error);
	}
}
Пример #17
0
static guint
append_menu_item (PlacemarksPlugin *plugin,
                  const gchar *id,
                  const gchar *name)
{
  PlacemarksPluginPrivate *priv;
  GtkUIManager *manager;
  GError *error = NULL;
  gchar * item_ui_definition;
  GtkActionEntry actions[] = {
    { id,
      NULL,
      name,
      NULL,
      N_("Go to this placemark"),
      G_CALLBACK (go_cb) }
  };
  guint ui_id;

  priv = PLACEMARKS_PLUGIN (plugin)->priv;
  manager = emerillon_window_get_ui_manager (priv->window);

  item_ui_definition = g_strconcat (
    "<ui>"
      "<menubar name=\"MainMenu\">"
        "<placeholder name=\"PluginsMenu\">"
          "<menu name=\"Placemarks\" action=\"PlacemarksMenu\">"
            "<placeholder name=\"PlacemarksGoItems\" action=\"PlacemarksGoItems\">"
              "<menuitem action=\"", id, "\"/>"
            "</placeholder>"
          "</menu>"
        "</placeholder>"
      "</menubar>"
    "</ui>", NULL);


  gtk_action_group_add_actions (priv->menu_action_group,
                                actions,
                                G_N_ELEMENTS (actions),
                                plugin);

  ui_id = gtk_ui_manager_add_ui_from_string (manager,
                                             item_ui_definition,
                                             -1, &error);
  if (ui_id == 0)
    {
      g_warning ("Error adding UI %s", error->message);
      g_error_free (error);
    }

  g_free (item_ui_definition);
  return ui_id;
}
Пример #18
0
static void on_file_clicked(FmFolderView* fv, FmFolderViewClickType type, FmFileInfo* fi, FmMainWin* win)
{
    char* fpath, *uri;
    GAppLaunchContext* ctx;
    switch(type)
    {
    case FM_FV_ACTIVATED: /* file activated */
        if(fm_file_info_is_dir(fi))
        {
            fm_main_win_chdir( win, fi->path);
        }
        else if(fi->target) /* FIXME: use accessor functions. */
        {
			/* FIXME: use FmPath here. */
            fm_main_win_chdir_by_name( win, fi->target);
        }
        else
        {
            fm_launch_file_simple(GTK_WINDOW(win), NULL, fi, open_folder_func, win);
        }
        break;
    case FM_FV_CONTEXT_MENU:
        if(fi)
        {
            FmFileMenu* menu;
            GtkMenu* popup;
            FmFileInfoList* files = fm_folder_view_get_selected_files(fv);
            menu = fm_file_menu_new_for_files(files, TRUE);
            fm_file_menu_set_folder_func(menu, open_folder_func, win);
            fm_list_unref(files);

            /* merge some specific menu items for folders */
            if(fm_file_menu_is_single_file_type(menu) && fm_file_info_is_dir(fi))
            {
                GtkUIManager* ui = fm_file_menu_get_ui(menu);
                GtkActionGroup* act_grp = fm_file_menu_get_action_group(menu);
                gtk_action_group_add_actions(act_grp, folder_menu_actions, G_N_ELEMENTS(folder_menu_actions), win);
                gtk_ui_manager_add_ui_from_string(ui, folder_menu_xml, -1, NULL);
            }

            popup = fm_file_menu_get_menu(menu);
            gtk_menu_popup(popup, NULL, NULL, NULL, fi, 3, gtk_get_current_event_time());
        }
        else /* no files are selected. Show context menu of current folder. */
        {
            gtk_menu_popup(GTK_MENU(win->popup), NULL, NULL, NULL, NULL, 3, gtk_get_current_event_time());
        }
        break;
    case FM_FV_MIDDLE_CLICK:
        g_debug("middle click!");
        break;
    }
}
Пример #19
0
static gboolean on_view_button_press( GtkTreeView* view, GdkEventButton* evt, FindFile* data )
{
    if( evt->type == GDK_BUTTON_PRESS )
    {
        if( evt->button == 3 ) /* right single click */
        {
            //sfm if current item not selected, unselect all and select it
            GtkTreePath *tree_path;
            GtkTreeSelection* tree_sel;
            gtk_tree_view_get_path_at_pos( GTK_TREE_VIEW( view ),
                                           evt->x, evt->y, &tree_path, NULL, NULL, NULL );
            tree_sel = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );

            if ( tree_path && tree_sel && 
                        !gtk_tree_selection_path_is_selected( tree_sel, tree_path ) )
            {
                gtk_tree_selection_unselect_all( tree_sel );
                gtk_tree_selection_select_path( tree_sel, tree_path );
            }
            gtk_tree_path_free( tree_path );
            
            GtkWidget* popup;
            GtkUIManager* menu_mgr;
            GtkActionGroup* action_group = gtk_action_group_new ("PopupActions");
            gtk_action_group_set_translation_domain( action_group, GETTEXT_PACKAGE );
            menu_mgr = gtk_ui_manager_new ();

            gtk_action_group_add_actions( action_group, menu_actions, G_N_ELEMENTS(menu_actions), data );
            gtk_ui_manager_insert_action_group( menu_mgr, action_group, 0 );
            gtk_ui_manager_add_ui_from_string( menu_mgr, menu_def, -1, NULL );

            popup = gtk_ui_manager_get_widget( menu_mgr, "/Popup" );
            g_object_unref( action_group );
            gtk_menu_popup( GTK_MENU( popup ), NULL, NULL, NULL, NULL, evt->button, evt->time );

            /* clean up */
            g_signal_connect( popup, "selection-done", G_CALLBACK(gtk_widget_destroy), NULL );
            g_object_weak_ref( G_OBJECT( popup ), (GWeakNotify)g_object_unref, menu_mgr );

            return TRUE;
        }
    }
    else if( evt->type == GDK_2BUTTON_PRESS )
    {
        if( evt->button == 1 )  /* left double click */
        {
            on_open_files( NULL, data );
            return TRUE;
        }
    }
    return FALSE;
}
static void
mail_attachment_handler_constructed (GObject *object)
{
	EMailAttachmentHandlerPrivate *priv;
	EShell *shell;
	EShellBackend *shell_backend;
	EAttachmentHandler *handler;
	EAttachmentView *view;
	GtkActionGroup *action_group;
	GtkUIManager *ui_manager;
	GError *error = NULL;

	handler = E_ATTACHMENT_HANDLER (object);
	priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (object);

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (parent_class)->constructed (object);

	shell = e_shell_get_default ();
	shell_backend = e_shell_get_backend_by_name (shell, "mail");
	priv->backend = g_object_ref (shell_backend);

	view = e_attachment_handler_get_view (handler);

	action_group = e_attachment_view_add_action_group (view, "mail");
	gtk_action_group_add_actions (
		action_group, standard_entries,
		G_N_ELEMENTS (standard_entries), handler);

	ui_manager = e_attachment_view_get_ui_manager (view);
	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);

	if (error != NULL) {
		g_warning ("%s", error->message);
		g_error_free (error);
	}

	g_signal_connect (
		view, "update-actions",
		G_CALLBACK (mail_attachment_handler_update_actions),
		handler);

	g_signal_connect (
		view, "drag-data-received",
		G_CALLBACK (mail_attachment_handler_message_rfc822),
		handler);

	g_signal_connect (
		view, "drag-data-received",
		G_CALLBACK (mail_attachment_handler_x_uid_list),
		handler);
}
Пример #21
0
static void
impl_activate (PeasActivatable *plugin)
{
  PlacemarksPluginPrivate *priv;
  GtkUIManager *manager;
  GtkListStore *store;

  priv = PLACEMARKS_PLUGIN (plugin)->priv;
  priv->window = EMERILLON_WINDOW (emerillon_window_dup_default ());
  priv->map_view = emerillon_window_get_map_view (priv->window);

  priv->markers_layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_NONE);
  champlain_view_add_layer(priv->map_view, CHAMPLAIN_LAYER(priv->markers_layer));

  manager = emerillon_window_get_ui_manager (priv->window);

  priv->action_group = gtk_action_group_new ("PlacemarksActions");
  gtk_action_group_set_translation_domain (priv->action_group,
                                           GETTEXT_PACKAGE);
  gtk_action_group_add_actions (priv->action_group,
                                action_entries,
                                G_N_ELEMENTS (action_entries),
                                plugin);
  gtk_ui_manager_insert_action_group (manager,
                                      priv->action_group,
                                      -1);

  priv->ui_id = gtk_ui_manager_add_ui_from_string (manager,
                                                   ui_definition,
                                                   -1, NULL);
  g_warn_if_fail (priv->ui_id != 0);

  store = gtk_list_store_new (COL_COUNT,
                              G_TYPE_STRING,       /* ID */
                              G_TYPE_STRING,       /* Name */
                              G_TYPE_FLOAT,        /* Latitude */
                              G_TYPE_STRING,       /* Latitude as a string */
                              G_TYPE_FLOAT,        /* Longitude */
                              G_TYPE_STRING,       /* Longitude as a string */
                              G_TYPE_INT,          /* Zoom level */
                              G_TYPE_STRING,       /* Zoom level as a string */
                              G_TYPE_UINT,        /* UI ID */
                              G_TYPE_POINTER);       /* Marker pointer */
  priv->model = GTK_TREE_MODEL (store);
  priv->deleted_cb_id  =  g_signal_connect (priv->model,
                                            "row-deleted",
                                            G_CALLBACK (row_deleted_cb),
                                            plugin);

  load_placemarks (PLACEMARKS_PLUGIN (plugin));
  load_menus (PLACEMARKS_PLUGIN (plugin));
}
Пример #22
0
void action_init(GtkActionGroup **actiongroup, GtkUIManager **ui_manager)
{
	*actiongroup = gtk_action_group_new("Browser");

	/*添加动作到动作组,函数原型如下:
	  void gtk_action_group_add_actions(GtkActionGroup *action_group,
	  const GtkActionEntry *entries,
	  guint n_entries,
	  gpointer user_data);
	  意义很明显,
	  action_group是要添加到的组,
	  entries是要添加的动作数组
	  n_entries是待添加的动作中的动作元素数目
	  user_data应该就是给每个动作回调函数传入的参数。
	 * */
	gtk_action_group_add_actions(*actiongroup, menu_entries, menu_entries_n, "hi,in menu");
	gtk_action_group_add_actions(*actiongroup, toolbar_entries, toolbar_entries_n, "hi,in toolbar");

	/*添加动作相关信息到待建立的界面中*/
	*ui_manager = gtk_ui_manager_new();
	gtk_ui_manager_insert_action_group(*ui_manager, *actiongroup, 0);
}
Пример #23
0
/**
 * bastile_gpgme_generate_register:
 *
 * Registers the action group for the pgp key creation dialog
 *
 */
void
bastile_gpgme_generate_register (void)
{
	GtkActionGroup *actions;
	
	actions = gtk_action_group_new ("gpgme-generate");

	gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (actions, ACTION_ENTRIES, G_N_ELEMENTS (ACTION_ENTRIES), NULL);
	
	/* Register this as a generator */
	bastile_registry_register_object (NULL, G_OBJECT (actions), BASTILE_PGP_TYPE_STR, "generator", NULL);
}
Пример #24
0
Файл: log.c Проект: DINKIN/nip2
static void
log_build( GtkWidget *widget ) 
{
	Log *log = LOG( widget );
	iWindow *iwnd = IWINDOW( widget );
	LogClass *log_class = LOG_GET_CLASS( log );

	GError *error;
	GtkWidget *mbar;

	GtkWidget *swin;
	PangoFontDescription *font_desc;

	IWINDOW_CLASS( parent_class )->build( widget );

	gtk_action_group_add_actions( iwnd->action_group, 
		log_class->actions, log_class->n_actions, 
		GTK_WINDOW( log ) );
	gtk_action_group_add_toggle_actions( iwnd->action_group, 
		log_class->toggle_actions, log_class->n_toggle_actions, 
		GTK_WINDOW( log ) );

	if( !gtk_ui_manager_add_ui_from_string( iwnd->ui_manager,
		log_class->ui_description, -1, &error ) ) {
		g_message( "building menus failed: %s", error->message );
		g_error_free( error );
		exit( EXIT_FAILURE );
	}

	mbar = gtk_ui_manager_get_widget( iwnd->ui_manager, 
		log_class->menu_bar_name );
	gtk_box_pack_start( GTK_BOX( iwnd->work ), mbar, FALSE, FALSE, 0 );
        gtk_widget_show( mbar );

	swin = gtk_scrolled_window_new( NULL, NULL );
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( swin ),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
	gtk_box_pack_start( GTK_BOX( iwnd->work ), swin, TRUE, TRUE, 0 );
	gtk_widget_show( swin );

	log->view = gtk_text_view_new();
	gtk_text_view_set_editable( GTK_TEXT_VIEW( log->view ), FALSE );
	gtk_text_view_set_cursor_visible( GTK_TEXT_VIEW( log->view ), 
		FALSE );
	font_desc = pango_font_description_from_string( "Monospace" );
	gtk_widget_modify_font( log->view, font_desc );
	pango_font_description_free( font_desc );

	gtk_container_add( GTK_CONTAINER( swin ), log->view );
	gtk_widget_show( log->view );
}
Пример #25
0
Файл: menus.c Проект: GNOME/dia
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 ();
}
void
libre_impuesto_window_actions_init (LibreImpuestoWindow *impuesto_window)
{
  GtkActionGroup *action_group;
  GtkUIManager *ui_manager;
  gchar *filename;
  GError *error;
  gboolean ret_val;

  g_return_if_fail (IS_LIBRE_IMPUESTO_WINDOW (impuesto_window));

  ui_manager = libre_impuesto_window_get_ui_manager (impuesto_window);

  action_group  = libre_impuesto_add_action_group(ui_manager, "impuesto");

  gtk_action_group_add_actions ( action_group, impuesto_entries,
				 G_N_ELEMENTS (impuesto_entries), 
				 impuesto_window);

  gtk_action_group_add_toggle_actions (	action_group, impuesto_toggle_entries,
					G_N_ELEMENTS (impuesto_toggle_entries),
					impuesto_window);
  error = NULL;  
  filename = g_build_filename (LIBRE_IMPUESTO_UIDIR, 
			       "libre-impuestos-menu.ui", NULL);
  ret_val = gtk_ui_manager_add_ui_from_file (ui_manager, filename, &error);
  g_free (filename);
  if (!ret_val) {
    g_critical("%s", error->message); 
  }

  g_object_bind_property (impuesto_window, "headerbar-visible",
			  libre_impuesto_window_get_action (impuesto_window, 
							    "show-headerbar"), 
			  "active", G_BINDING_BIDIRECTIONAL | 
			  G_BINDING_SYNC_CREATE);

  g_object_bind_property (impuesto_window, "sidebar-visible",
			  libre_impuesto_window_get_action( impuesto_window,
							    "show-sidebar"), 
			  "active", G_BINDING_BIDIRECTIONAL | 
			  G_BINDING_SYNC_CREATE);

  g_object_bind_property (impuesto_window, "statusbar-visible",
			  libre_impuesto_window_get_action (impuesto_window, 
							    "show-statusbar"), 
			  "active", G_BINDING_BIDIRECTIONAL | 
			  G_BINDING_SYNC_CREATE);

}
Пример #27
0
gint plugin_gtk_init(gchar **error)
{
	MainWindow *mainwin = mainwindow_get_mainwindow();

	folderview_register_popup(&claws_mailmbox_popup);

	gtk_action_group_add_actions(mainwin->action_group, mainwindow_add_mailbox,
			1, (gpointer)mainwin);
	MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager, "/Menu/File/AddMailbox", "Mbox", 
			  "File/AddMailbox/Mbox", GTK_UI_MANAGER_MENUITEM,
			  main_menu_id)

	return 0;
}
Пример #28
0
/* folder view popups */
static void update_files_popup(FmFolderView* fv, GtkWindow* win,
                               GtkUIManager* ui, GtkActionGroup* act_grp,
                               FmFileInfoList* files)
{
    GList* l;

    for(l = fm_file_info_list_peek_head_link(files); l; l = l->next)
        if(!fm_file_info_is_dir(l->data))
            return; /* actions are valid only if all selected are directories */
    gtk_action_group_set_translation_domain(act_grp, NULL);
    gtk_action_group_add_actions(act_grp, folder_menu_actions,
                                 G_N_ELEMENTS(folder_menu_actions), win);
    gtk_ui_manager_add_ui_from_string(ui, folder_menu_xml, -1, NULL);
}
Пример #29
0
gboolean e_plugin_ui_init(GtkUIManager *ui_manager, EShellView *shell_view)
{
    EShellWindow *shell_window;
    GtkActionGroup *action_group;

    shell_window = e_shell_view_get_shell_window (shell_view);
    action_group = e_shell_window_get_action_group (shell_window, "calendar");

    gtk_action_group_add_actions (
        action_group, menuItems,
        G_N_ELEMENTS (menuItems), shell_view);

    return TRUE;
}
Пример #30
0
static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager)
{
	GtkActionGroup *action_group = gtk_action_group_new("Menu");
	gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0);

	gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
	GError* error = 0;
	gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ui_manager), ui_string, -1, &error);

	gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager));
	GtkWidget* menu = gtk_ui_manager_get_widget(ui_manager, "/MainMenu");

	return menu;
}