Пример #1
0
void
actions_toggle_add(GtkActionGroup *act_group, const struct _actionhooks *ahs,
    int count)
{
	int i;
	GtkToggleAction *action;
	char *nel = malloc(max_path);

	for (i = 0; i < count; i++) {
		char *label = gettext(ahs[i].label);
		action = gtk_toggle_action_new(ahs[i].name,
		  label, ahs[i].tooltip == NULL ? label :
		  gettext(ahs[i].tooltip),
		  ahs[i].icon == NULL ? ahs[i].name : ahs[i].icon);
		sprintf(nel, "<Actions>/actions/%s", ahs[i].name);
		gtk_action_set_accel_path(GTK_ACTION(action), nel);
		//gtk_action_connect_accelerator(action);
		g_signal_connect(G_OBJECT(action), "activate",
		    ahs[i].handler,
		    GINT_TO_POINTER(ahs[i].parameter));
		gtk_action_group_add_action_with_accel(act_group,
		    GTK_ACTION(action),
		  NULL);
	}
	free(nel);
}
Пример #2
0
static struct menu_priv *
add_menu(struct menu_priv *menu, struct menu_methods *meth, char *name, enum menu_type type, void (*callback)(struct menu *data_menu, void *data1, void *data2), struct menu *data_menu, void *data1, void *data2)
{
	struct menu_priv *ret;
	char *dynname;

	ret=g_new0(struct menu_priv, 1);
	*meth=menu_methods;
	if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Route")) {
		dynname=g_strdup("Route");
	} else {
		dynname=g_strdup_printf("%d", menu->gui->dyn_counter++);
		if (type == menu_type_toggle)
			ret->action=GTK_ACTION(gtk_toggle_action_new(dynname, name, NULL, NULL));
		else
			ret->action=gtk_action_new(dynname, name, NULL, NULL);
		if (callback)
			ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
		gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
		ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->menu_manager);
		gtk_ui_manager_add_ui( menu->gui->menu_manager, ret->merge_id, menu->path, dynname, dynname, type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
	}
	ret->gui=menu->gui;
	ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
	ret->type=type;
	ret->callback=callback;
	ret->callback_menu=data_menu;
	ret->callback_data1=data1;
	ret->callback_data2=data2;
	ret->sibling=menu->child;
	menu->child=ret;
	g_free(dynname);
	return ret;
		
}
Пример #3
0
GtkActionGroup *
nautilus_window_create_toolbar_action_group (NautilusWindow *window)
{
	NautilusNavigationState *navigation_state;
	GtkActionGroup *action_group;
	GtkAction *action;

	action_group = gtk_action_group_new ("ToolbarActions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);

	action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
			       "name", NAUTILUS_ACTION_BACK,
			       "label", _("_Back"),
			       "stock_id", GTK_STOCK_GO_BACK,
			       "tooltip", _("Go to the previous visited location"),
			       "arrow-tooltip", _("Back history"),
			       "window", window,
			       "direction", NAUTILUS_NAVIGATION_DIRECTION_BACK,
			       "sensitive", FALSE,
			       NULL);
	g_signal_connect (action, "activate",
			  G_CALLBACK (action_back_callback), window);
	gtk_action_group_add_action (action_group, action);

	g_object_unref (action);

	action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
			       "name", NAUTILUS_ACTION_FORWARD,
			       "label", _("_Forward"),
			       "stock_id", GTK_STOCK_GO_FORWARD,
			       "tooltip", _("Go to the next visited location"),
			       "arrow-tooltip", _("Forward history"),
			       "window", window,
			       "direction", NAUTILUS_NAVIGATION_DIRECTION_FORWARD,
			       "sensitive", FALSE,
			       NULL);
	g_signal_connect (action, "activate",
			  G_CALLBACK (action_forward_callback), window);
	gtk_action_group_add_action (action_group, action);

	g_object_unref (action);

	action = GTK_ACTION
		(gtk_toggle_action_new (NAUTILUS_ACTION_SEARCH,
					_("Search"),
					_("Search documents and folders by name"),
					NULL));
	gtk_action_group_add_action (action_group, action);
	gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic");
	gtk_action_set_is_important (GTK_ACTION (action), TRUE);

	g_object_unref (action);

	navigation_state = nautilus_window_get_navigation_state (window);
	nautilus_navigation_state_add_group (navigation_state, action_group);

	return action_group;
}
Пример #4
0
int main(int argc, char *argv[])
{
    gtk_init(&argc, &argv);
    
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
    g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
    
    GtkWidget *menubar = gtk_menu_bar_new();
    gtk_container_add(GTK_CONTAINER(window), menubar);

    GtkActionGroup *actiongroup = gtk_action_group_new("ActionGroup");
    
    GtkAction *action = gtk_action_new("actionFile", "_File", NULL, NULL);
    gtk_action_group_add_action(GTK_ACTION_GROUP(actiongroup), action);
    GtkWidget *menuitemFile = gtk_action_create_menu_item(GTK_ACTION(action));
    gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitemFile);
    
    GtkWidget *menu = gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitemFile), menu);
    
    GtkToggleAction *toggleaction;
    
    toggleaction = gtk_toggle_action_new("actionNew", "_New", "Create a new document", GTK_STOCK_NEW);
    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggleaction), TRUE);
    gtk_action_group_add_action(GTK_ACTION_GROUP(actiongroup), GTK_ACTION(toggleaction));
    GtkWidget *menuitemNew = gtk_action_create_menu_item(GTK_ACTION(toggleaction));
    gtk_menu_append(GTK_MENU(menu), menuitemNew);
    toggleaction = gtk_toggle_action_new("actionOpen", "_Open", "Open a file", GTK_STOCK_OPEN);
    gtk_action_group_add_action(GTK_ACTION_GROUP(actiongroup), GTK_ACTION(toggleaction));
    GtkWidget *menuitemOpen = gtk_action_create_menu_item(GTK_ACTION(toggleaction));
    gtk_menu_append(GTK_MENU(menu), menuitemOpen);
    toggleaction = gtk_toggle_action_new("actionSave", "_Save", "Save a file", GTK_STOCK_SAVE);
    gtk_action_group_add_action(GTK_ACTION_GROUP(actiongroup), GTK_ACTION(toggleaction));
    GtkWidget *menuitemSave = gtk_action_create_menu_item(GTK_ACTION(toggleaction));
    gtk_menu_append(GTK_MENU(menu), menuitemSave);

    gtk_widget_show_all(window);
    
    gtk_main();
    
    return 0;
}
Пример #5
0
int
clip_GTK_TOGGLEACTIONNEW(ClipMachine * ClipMachineMemory)
{
   ClipVar  *cv = _clip_spar(ClipMachineMemory, 1);

   gchar    *name = _clip_parc(ClipMachineMemory, 2);

   gchar    *label = _clip_parc(ClipMachineMemory, 3);

   gchar    *tooltip = _clip_parc(ClipMachineMemory, 4);

   gchar    *stock_id = _clip_parc(ClipMachineMemory, 5);

   C_object *caction;

   GtkToggleAction *action;

   CHECKOPT(1, MAP_type_of_ClipVarType);
   CHECKARG(2, CHARACTER_type_of_ClipVarType);
   CHECKARG(3, CHARACTER_type_of_ClipVarType);
   CHECKOPT(4, CHARACTER_type_of_ClipVarType);
   CHECKOPT(5, CHARACTER_type_of_ClipVarType);

   LOCALE_TO_UTF(name);
   LOCALE_TO_UTF(label);
   if (tooltip)
      LOCALE_TO_UTF(tooltip);
   if (stock_id)
      LOCALE_TO_UTF(stock_id);

   action = gtk_toggle_action_new(name, label, tooltip, stock_id);

   if (action)
    {
       caction = _list_get_cobject(ClipMachineMemory, action);
       if (!caction)
	  caction = _register_object(ClipMachineMemory, action, GTK_TYPE_TOGGLE_ACTION, cv, NULL);
       if (caction)
	  _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &caction->obj);
    }

   FREE_TEXT(name);
   FREE_TEXT(label);
   if (tooltip)
      FREE_TEXT(tooltip);
   if (stock_id)
      FREE_TEXT(stock_id);
   return 0;
 err:
   return 1;
}
Пример #6
0
static GtkAction*
create_action_for_view_menu (PgpugPane *pane)
{
     g_return_if_fail (PGPUG_IS_PANE (pane));

     const gchar *name = pgpug_pane_get_menu_text (pane);
     GtkToggleAction *action = gtk_toggle_action_new (name, name, NULL, NULL);

     gboolean is_pane_installed = gtk_widget_get_parent (pgpug_pane_get_view (pane)) != NULL;
     gtk_toggle_action_set_active (action, is_pane_installed);
     g_signal_connect (action, "toggled", G_CALLBACK (menu_view_item_toggled), pane);

     return GTK_ACTION (action);

}
Пример #7
0
static VALUE
taction_initialize(VALUE self, VALUE name, VALUE label, VALUE tooltip, VALUE stock_id)
{
    const gchar *gstockid = NULL;

    if (TYPE(stock_id) == T_SYMBOL){
        gstockid = rb_id2name(SYM2ID(stock_id));
    } else if (TYPE(stock_id) == T_STRING){
        gstockid = RVAL2CSTR(stock_id);
    }

    G_INITIALIZE(self, gtk_toggle_action_new(RVAL2CSTR(name),
                                             RVAL2CSTR(label),
                                             NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip),
                                             gstockid));
    return Qnil;
}
Пример #8
0
/*! \brief Translate a resource tree into a menu structure
 *
 *  \param [in] menu    The GHidMainMenu widget to be acted on
 *  \param [in] shall   The base menu shell (a menu bar or popup menu)
 *  \param [in] res     The base of the resource tree
 * */
void
ghid_main_menu_real_add_resource (GHidMainMenu *menu, GtkMenuShell *shell,
                                  const Resource *res)
{
    int i, j;
    const Resource *tmp_res;
    gchar mnemonic = 0;

    for (i = 0; i < res->c; ++i)
    {
        const gchar *accel = NULL;
        char *menu_label;
        const char *res_val;
        const Resource *sub_res = res->v[i].subres;
        GtkAction *action = NULL;

        switch (resource_type (res->v[i]))
        {
        case 101:   /* name, subres: passthrough */
            ghid_main_menu_real_add_resource (menu, shell, sub_res);
            break;
        case   1:   /* no name, subres */
            tmp_res = resource_subres (sub_res, "a");  /* accelerator */
            res_val = resource_value (sub_res, "m");   /* mnemonic */
            if (res_val)
                mnemonic = res_val[0];
            /* The accelerator resource will have two values, like
             *   a={"Ctrl-Q" "Ctrl<Key>q"}
             * The first Gtk ignores. The second needs to be translated. */
            if (tmp_res)
                accel = check_unique_accel
                        (translate_accelerator (tmp_res->v[1].value));

            /* Now look for the first unnamed value (not a subresource) to
             * figure out the name of the menu or the menuitem. */
            res_val = "button";
            for (j = 0; j < sub_res->c; ++j)
                if (resource_type (sub_res->v[j]) == 10)
                {
                    res_val = _(sub_res->v[j].value);
                    break;
                }
            /* Hack '_' in based on mnemonic value */
            if (!mnemonic)
                menu_label = g_strdup (res_val);
            else
            {
                char *post_ = strchr (res_val, mnemonic);
                if (post_ == NULL)
                    menu_label = g_strdup (res_val);
                else
                {
                    GString *tmp = g_string_new ("");
                    g_string_append_len (tmp, res_val, post_ - res_val);
                    g_string_append_c (tmp, '_');
                    g_string_append (tmp, post_);
                    menu_label = g_string_free (tmp, FALSE);
                }
            }
            /* If the subresource we're processing also has unnamed
             * subresources, it's a submenu, not a regular menuitem. */
            if (sub_res->flags & FLAG_S)
            {
                /* SUBMENU */
                GtkWidget *submenu = gtk_menu_new ();
                GtkWidget *item = gtk_menu_item_new_with_mnemonic (menu_label);
                GtkWidget *tearoff = gtk_tearoff_menu_item_new ();

                gtk_menu_shell_append (shell, item);
                gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);

                /* add tearoff to menu */
                gtk_menu_shell_append (GTK_MENU_SHELL (submenu), tearoff);
                /* recurse on the newly-added submenu */
                ghid_main_menu_real_add_resource (menu,
                                                  GTK_MENU_SHELL (submenu),
                                                  sub_res);
            }
            else
            {
                /* NON-SUBMENU: MENU ITEM */
                const char *checked = resource_value (sub_res, "checked");
                const char *label = resource_value (sub_res, "sensitive");
                const char *tip = resource_value (sub_res, "tip");
                if (checked)
                {
                    /* TOGGLE ITEM */
                    gchar *name = g_strdup_printf ("MainMenuAction%d",
                                                   action_counter++);

                    action = GTK_ACTION (gtk_toggle_action_new (name, menu_label,
                                         tip, NULL));
                    /* checked=foo       is a binary flag (checkbox)
                     * checked=foo,bar   is a flag compared to a value (radio) */
                    gtk_toggle_action_set_draw_as_radio
                    (GTK_TOGGLE_ACTION (action), !!strchr (checked, ','));
                }
                else if (label && strcmp (label, "false") == 0)
                {
                    /* INSENSITIVE ITEM */
                    GtkWidget *item = gtk_menu_item_new_with_label (menu_label);
                    gtk_widget_set_sensitive (item, FALSE);
                    gtk_menu_shell_append (shell, item);
                }
                else
                {
                    /* NORMAL ITEM */
                    gchar *name = g_strdup_printf ("MainMenuAction%d", action_counter++);
                    action = gtk_action_new (name, menu_label, tip, NULL);
                }
            }
            /* Connect accelerator, if there is one */
            if (action)
            {
                GtkWidget *item;
                gtk_action_set_accel_group (action, menu->accel_group);
                gtk_action_group_add_action_with_accel (menu->action_group,
                                                        action, accel);
                gtk_action_connect_accelerator (action);
                g_signal_connect (G_OBJECT (action), "activate", menu->action_cb,
                                  (gpointer) sub_res);
                g_object_set_data (G_OBJECT (action), "resource",
                                   (gpointer) sub_res);
                item = gtk_action_create_menu_item (action);
                gtk_menu_shell_append (shell, item);
                menu->actions = g_list_append (menu->actions, action);
                menu->special_key_cb (accel, action, sub_res);
            }
            /* Scan rest of resource in case there is more work */
            for (j = 0; j < sub_res->c; j++)
            {
                const char *res_name;
                /* named value = X resource */
                if (resource_type (sub_res->v[j]) == 110)
                {
                    res_name = sub_res->v[j].name;

                    /* translate bg, fg to background, foreground */
                    if (strcmp (res_name, "fg") == 0)   res_name = "foreground";
                    if (strcmp (res_name, "bg") == 0)   res_name = "background";

                    /* ignore special named values (m, a, sensitive) */
                    if (strcmp (res_name, "m") == 0
                            || strcmp (res_name, "a") == 0
                            || strcmp (res_name, "sensitive") == 0
                            || strcmp (res_name, "tip") == 0)
                        break;

                    /* log checked and active special values */
                    if (action && strcmp (res_name, "checked") == 0)
                        g_object_set_data (G_OBJECT (action), "checked-flag",
                                           sub_res->v[j].value);
                    else if (action && strcmp (res_name, "active") == 0)
                        g_object_set_data (G_OBJECT (action), "active-flag",
                                           sub_res->v[j].value);
                    else
                        /* if we got this far it is supposed to be an X
                         * resource.  For now ignore it and warn the user */
                        Message (_("The gtk gui currently ignores \"%s\""
                                   "as part of a menuitem resource.\n"
                                   "Feel free to provide patches\n"),
                                 sub_res->v[j].value);
                }
            }
            break;
        case  10:   /* no name, value */
            /* If we get here, the resource is "-" or "@foo" for some foo */
            if (res->v[i].value[0] == '@')
            {
                GList *children;
                int pos;

                children = gtk_container_get_children (GTK_CONTAINER (shell));
                pos = g_list_length (children);
                g_list_free (children);

                if (strcmp (res->v[i].value, "@layerview") == 0)
                {
                    menu->layer_view_shell = shell;
                    menu->layer_view_pos = pos;
                }
                else if (strcmp (res->v[i].value, "@layerpick") == 0)
                {
                    menu->layer_pick_shell = shell;
                    menu->layer_pick_pos = pos;
                }
                else if (strcmp (res->v[i].value, "@routestyles") == 0)
                {
                    menu->route_style_shell = shell;
                    menu->route_style_pos = pos;
                }
                else
                    Message (_("GTK GUI currently ignores \"%s\" in the menu\n"
                               "resource file.\n"), res->v[i].value);
            }
            else if (strcmp (res->v[i].value, "-") == 0)
            {
                GtkWidget *item = gtk_separator_menu_item_new ();
                gtk_menu_shell_append (shell, item);
            }
            else if (i > 0)
            {
                /* This is an action-less menuitem. It is really only useful
                 * when you're starting to build a new menu and you're looking
                 * to get the layout right. */
                GtkWidget *item
                    = gtk_menu_item_new_with_label (_(res->v[i].value));
                gtk_menu_shell_append (shell, item);
            }
            break;
        }
    }
}
static void
toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
{
  EggEditableToolbarPrivate *priv = etoolbar->priv;
  gint n_toolbars, n_items, i, j, k;
  GtkToggleAction *action;
  GList *list;
  GString *string;
  gboolean showing;
  char action_name[40];
  char *action_label;
  char *tmp;

  if (priv == NULL || priv->model == NULL || priv->manager == NULL ||
      priv->visibility_paths == NULL || priv->actions == NULL)
    {
      return;
    }

  if (priv->visibility_actions == NULL)
    {
      priv->visibility_actions = g_ptr_array_new ();
    }

  if (priv->visibility_id != 0)
    {
      gtk_ui_manager_remove_ui (priv->manager, priv->visibility_id);
    }

  priv->visibility_id = gtk_ui_manager_new_merge_id (priv->manager);

  showing = gtk_widget_get_visible (GTK_WIDGET (etoolbar));

  n_toolbars = egg_toolbars_model_n_toolbars (priv->model);
  for (i = 0; i < n_toolbars; i++)
    {
      string = g_string_sized_new (0);
      n_items = egg_toolbars_model_n_items (priv->model, i);
      for (k = 0, j = 0; j < n_items; j++)
        {
          GValue value = { 0, };
          GtkAction *action;
          const char *name;

          name = egg_toolbars_model_item_nth (priv->model, i, j);
          if (name == NULL) continue;
          action = find_action (etoolbar, name);
          if (action == NULL) continue;

          g_value_init (&value, G_TYPE_STRING);
          g_object_get_property (G_OBJECT (action), "label", &value);
          name = g_value_get_string (&value);
          if (name == NULL)
	    {
		g_value_unset (&value);
		continue;
	    }
	  k += g_utf8_strlen (name, -1) + 2;
	  if (j > 0)
	    {
	      g_string_append (string, ", ");
	      if (j > 1 && k > 25)
		{
		  g_value_unset (&value);
		  break;
		}
	    }
	  g_string_append (string, name);
	  g_value_unset (&value);
	}
      if (j < n_items)
        {
	  g_string_append (string, " ...");
        }

      tmp = g_string_free (string, FALSE);
      for (j = 0, k = 0; tmp[j]; j++)
      {
	if (tmp[j] == '_') continue;
	tmp[k] = tmp[j];
	k++;
      }
      tmp[k] = 0;
      /* Translaters: This string is for a toggle to display a toolbar.
       * The name of the toolbar is automatically computed from the widgets
       * on the toolbar, and is placed at the %s. Note the _ before the %s
       * which is used to add mnemonics. We know that this is likely to
       * produce duplicates, but don't worry about it. If your language
       * normally has a mnemonic at the start, please use the _. If not,
       * please remove. */
      action_label = g_strdup_printf (_("Show “_%s”"), tmp);
      g_free (tmp);

      sprintf(action_name, "ToolbarToggle%d", i);

      if (i >= priv->visibility_actions->len)
        {
	  action = gtk_toggle_action_new (action_name, action_label, NULL, NULL);
	  g_ptr_array_add (priv->visibility_actions, action);
	  g_signal_connect_object (action, "toggled",
				   G_CALLBACK (toggled_visibility_cb),
				   etoolbar, 0);
	  gtk_action_group_add_action (priv->actions, GTK_ACTION (action));
	}
      else
        {
	  action = g_ptr_array_index (priv->visibility_actions, i);
	  g_object_set (action, "label", action_label, NULL);
        }

      gtk_action_set_visible (GTK_ACTION (action), (egg_toolbars_model_get_flags (priv->model, i)
						    & EGG_TB_MODEL_NOT_REMOVABLE) == 0);
      gtk_action_set_sensitive (GTK_ACTION (action), showing);
      gtk_toggle_action_set_active (action, gtk_widget_get_visible
				    (get_dock_nth (etoolbar, i)));

      for (list = priv->visibility_paths; list != NULL; list = g_list_next (list))
        {
	  gtk_ui_manager_add_ui (priv->manager, priv->visibility_id,
				 (const char *)list->data, action_name, action_name,
				 GTK_UI_MANAGER_MENUITEM, FALSE);
	}

      g_free (action_label);
    }

  gtk_ui_manager_ensure_update (priv->manager);

  while (i < priv->visibility_actions->len)
    {
      action = g_ptr_array_index (priv->visibility_actions, i);
      g_ptr_array_remove_index_fast (priv->visibility_actions, i);
      gtk_action_group_remove_action (priv->actions, GTK_ACTION (action));
      i++;
    }
}
Пример #10
0
static void
impl_activate (PeasActivatable *activatable)
{
	RBVisualizerPlugin *pi = RB_VISUALIZER_PLUGIN (activatable);
	RBDisplayPageGroup *page_group;
	RhythmDBEntry *entry;
	GtkToggleAction *fullscreen;
	GtkWidget *menu;
	RBShell *shell;

	g_object_get (pi, "object", &shell, NULL);

	pi->settings = g_settings_new ("org.gnome.rhythmbox.plugins.visualizer");
	g_signal_connect_object (pi->settings, "changed", G_CALLBACK (settings_changed_cb), pi, 0);

	/* create UI actions and menus and stuff */
	fullscreen = gtk_toggle_action_new ("VisualizerFullscreen",
					    _("Fullscreen"),
					    _("Toggle fullscreen visual effects"),
					    GTK_STOCK_FULLSCREEN);
	menu = rb_visualizer_create_popup_menu (fullscreen);
	g_object_ref_sink (menu);

	/* create visualizer page */
	pi->page = rb_visualizer_page_new (G_OBJECT (pi), shell, fullscreen, menu);
	g_signal_connect_object (pi->page, "start", G_CALLBACK (start_visualizer_cb), pi, 0);
	g_signal_connect_object (pi->page, "stop", G_CALLBACK (stop_visualizer_cb), pi, 0);

	/* don't do anything if we couldn't create a video sink (clutter is broken, etc.) */
	g_object_get (pi->page, "sink", &pi->sink, NULL);
	if (pi->sink == NULL) {
		g_object_unref (shell);
		return;
	}

	/* prepare style stuff for fullscreen display */
	rb_visualizer_fullscreen_load_style (G_OBJECT (pi));

	/* add the visualizer page to the UI */
	page_group = rb_display_page_group_get_by_id ("display");
	if (page_group == NULL) {
		page_group = rb_display_page_group_new (G_OBJECT (shell),
							"display",
							_("Display"),
							RB_DISPLAY_PAGE_GROUP_CATEGORY_TOOLS);
		rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (page_group), NULL);
	}
	g_object_set (pi->page, "visibility", FALSE, NULL);

	rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (pi->page), RB_DISPLAY_PAGE (page_group));

	/* get player objects */
	g_object_get (shell, "shell-player", &pi->shell_player, NULL);
	g_object_get (pi->shell_player, "player", &pi->player, NULL);

	/* only show the page in the page tree when playing something */
	g_signal_connect_object (pi->shell_player, "playing-song-changed", G_CALLBACK (playing_song_changed_cb), pi, 0);
	entry = rb_shell_player_get_playing_entry (pi->shell_player);
	playing_song_changed_cb (pi->shell_player, entry, pi);
	if (entry != NULL) {
		rhythmdb_entry_unref (entry);
	}

	/* figure out how to insert the visualizer into the playback pipeline */
	if (g_object_class_find_property (G_OBJECT_GET_CLASS (pi->player), "playbin")) {

		rb_debug ("using playbin-based visualization");
		pi->playbin_notify_id = g_signal_connect_object (pi->player,
								 "notify::playbin",
								 G_CALLBACK (playbin_notify_cb),
								 pi,
								 0);
		g_object_get (pi->player, "playbin", &pi->playbin, NULL);
		if (pi->playbin != NULL) {
			mutate_playbin (pi, pi->playbin);
		}
	} else if (RB_IS_PLAYER_GST_TEE (pi->player)) {
		rb_debug ("using tee-based visualization");
	} else {
		g_warning ("unknown player backend type");
		g_object_unref (pi->player);
		pi->player = NULL;
	}

	g_object_unref (shell);
}
Пример #11
0
GtkActionGroup *
nemo_window_create_toolbar_action_group (NemoWindow *window)
{
	gboolean show_label_search_icon_toolbar;

	NemoNavigationState *navigation_state;
	GtkActionGroup *action_group;
	GtkAction *action;

	action_group = gtk_action_group_new ("ToolbarActions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);

	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
			       "name", NEMO_ACTION_BACK,
			       "label", _("_Back"),
			       "stock_id", GTK_STOCK_GO_BACK,
			       "tooltip", _("Go to the previous visited location"),
			       "arrow-tooltip", _("Back history"),
			       "window", window,
			       "direction", NEMO_NAVIGATION_DIRECTION_BACK,
			       "sensitive", FALSE,
			       NULL);
	g_signal_connect (action, "activate",
			  G_CALLBACK (action_back_callback), window);
	gtk_action_group_add_action (action_group, action);

	g_object_unref (action);

	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
			       "name", NEMO_ACTION_FORWARD,
			       "label", _("_Forward"),
			       "stock_id", GTK_STOCK_GO_FORWARD,
			       "tooltip", _("Go to the next visited location"),
			       "arrow-tooltip", _("Forward history"),
			       "window", window,
			       "direction", NEMO_NAVIGATION_DIRECTION_FORWARD,
			       "sensitive", FALSE,
			       NULL);
	g_signal_connect (action, "activate",
			  G_CALLBACK (action_forward_callback), window);
	gtk_action_group_add_action (action_group, action);

	g_object_unref (action);

	/**
	 * Nemo 2.30/2.32 type actions
	 */
   	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
   			       "name", NEMO_ACTION_UP,
   			       "label", _("_Up"),
   			       "stock_id", GTK_STOCK_GO_UP,
   			       "tooltip", _("Go to parent folder"),
   			       "arrow-tooltip", _("Forward history"),
   			       "window", window,
   			       "direction", NEMO_NAVIGATION_DIRECTION_UP,
   			       NULL);
   	g_signal_connect (action, "activate",
   			  G_CALLBACK (action_up_callback), window);
   	gtk_action_group_add_action (action_group, action);
   
   	g_object_unref (action);
  
   	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
   			       "name", NEMO_ACTION_RELOAD,
   			       "label", _("_Reload"),
   			       "stock_id", GTK_STOCK_REFRESH,
   			       "tooltip", _("Reload the current location"),
   			       "window", window,
   			       "direction", NEMO_NAVIGATION_DIRECTION_RELOAD,
   			       NULL);
   	g_signal_connect (action, "activate",
   			  G_CALLBACK (action_reload_callback), window);
   	gtk_action_group_add_action (action_group, action);
   	
   	g_object_unref (action);
   
   	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
   			       "name", NEMO_ACTION_HOME,
   			       "label", _("_Home"),
   			       "stock_id", GTK_STOCK_HOME,
   			       "tooltip", _("Go to home directory"),
   			       "window", window,
   			       "direction", NEMO_NAVIGATION_DIRECTION_HOME,
   			       NULL);
   	g_signal_connect (action, "activate",
   			  G_CALLBACK (action_home_callback), window);
   	gtk_action_group_add_action (action_group, action);
   
   	g_object_unref (action);
   
   	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
   			       "name", NEMO_ACTION_COMPUTER,
   			       "label", _("_Computer"),
   			       "icon_name", "computer",
   			       "tooltip", _("Go to Computer"),
   			       "window", window,
   			       "direction", NEMO_NAVIGATION_DIRECTION_COMPUTER,
   			       NULL);
   	g_signal_connect (action, "activate",
   			  G_CALLBACK (action_go_to_computer_callback), window);
   	gtk_action_group_add_action (action_group, action);
   
   	g_object_unref (action);
 
   	action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION,
   			       "name", NEMO_ACTION_EDIT_LOCATION,
   			       "label", _("Location"),
   			       "stock_id", GTK_STOCK_EDIT,
   			       "tooltip", _("Toggle Location bar / Path bar"),
   			       "window", window,
    			       "direction", NEMO_NAVIGATION_DIRECTION_EDIT,
   			       NULL);
   	g_signal_connect (action, "activate",
   			  G_CALLBACK (action_edit_location_callback), window);
   	gtk_action_group_add_action (action_group, action);
  
   	g_object_unref (action);

 	action = GTK_ACTION (gtk_toggle_action_new (NEMO_ACTION_SEARCH,
 				_("Search"),_("Search documents and folders by name"),
 				NULL));
 
  	gtk_action_group_add_action (action_group, action);
  	gtk_action_set_icon_name (GTK_ACTION (action), "edit-find");
 
 
 	show_label_search_icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR);
 	gtk_action_set_is_important (GTK_ACTION (action), show_label_search_icon_toolbar);
  
  	g_object_unref (action);

	navigation_state = nemo_window_get_navigation_state (window);
	nemo_navigation_state_add_group (navigation_state, action_group);

	return action_group;
}
Пример #12
0
 GtkAction * create_action_by_descriptor(const gchar *name, struct action_descriptor *data)
 {
	int			state		= data->attr.key_state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_ALT_MASK);
	int			f;

//	Trace("%s: %d",name,data->ui_type);

	switch(data->ui_type)
	{
	case UI_CALLBACK_TYPE_TOGGLE:
		data->action = GTK_ACTION(gtk_toggle_action_new(name, gettext(data->attr.label ? data->attr.label : data->name), gettext(data->attr.tooltip), data->attr.stock_id));
		break;

	case UI_CALLBACK_TYPE_DEFAULT:
		data->action = gtk_action_new(name, gettext(data->attr.label ? data->attr.label : data->name), gettext(data->attr.tooltip),data->attr.stock_id);
		break;

	case UI_CALLBACK_TYPE_SCROLL:
		if(data->sub >= 0 && data->sub <= G_N_ELEMENTS(action_scroll))
			action_scroll[data->sub] = data->action = gtk_action_new(name, gettext(data->attr.label ? data->attr.label : data->name), gettext(data->attr.tooltip),data->attr.stock_id);
		break;

	case UI_CALLBACK_TYPE_SCRIPT:

		if(data->script.text)
			g_object_set_data_full(G_OBJECT(data->action),"script_text",g_strdup(data->script.text),g_free);

		if(data->callback)
			g_signal_connect(G_OBJECT(data->action),"activate",G_CALLBACK(data->callback),topwindow);
		else
			g_signal_connect(G_OBJECT(data->action),"activate",G_CALLBACK(action_script_activated),topwindow);

		data->callback = 0;
		break;

	default:
		Trace("Invalid action type %d in %s",data->ui_type,data->name);
		return NULL;
	}

//	Trace("%s(%s), callback: %p action: %p",__FUNCTION__,name,data->callback,data->action);

	if(data->callback)
		g_signal_connect(G_OBJECT(data->action),data->ui_type == UI_CALLBACK_TYPE_TOGGLE ? "toggled" : "activate",G_CALLBACK(data->callback),data->user_data);

	// Check for special keyboard action
	for(f=0;f<G_N_ELEMENTS(keyboard_action);f++)
	{
		if(data->attr.key_value == keyboard_action[f].keyval && (state == keyboard_action[f].state))
		{
			keyboard_action[f].action = data->action;
			gtk_action_group_add_action(action_group[data->group],data->action);
			return data->action;
		}
	}

	// Check for PF actions
	if(data->attr.key_value >= GDK_F1 && data->attr.key_value <= GDK_F12 && !(state & (GDK_CONTROL_MASK|GDK_ALT_MASK)))
	{
		f = data->attr.key_value - GDK_F1;

		if(state&GDK_SHIFT_MASK)
			pf_action[f].shift = data->action;
		else
			pf_action[f].normal = data->action;
		gtk_action_group_add_action(action_group[data->group],data->action);
		return data->action;
	}

	// Register action
	if(data->attr.accel)
		gtk_action_group_add_action_with_accel(action_group[data->group],data->action,data->attr.accel);
	else
		gtk_action_group_add_action(action_group[data->group],data->action);

	return data->action;
 }