Example #1
0
static void
charset_combo_box_constructed (GObject *object)
{
	ECharsetComboBoxPrivate *priv;
	GtkRadioAction *radio_action;
	GSList *group;

	priv = E_CHARSET_COMBO_BOX_GET_PRIVATE (object);

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

	radio_action = priv->other_action;
	group = gtk_radio_action_get_group (radio_action);

	e_action_combo_box_set_action (
		E_ACTION_COMBO_BOX (object), radio_action);

	e_action_combo_box_add_separator_after (
		E_ACTION_COMBO_BOX (object), g_slist_length (group));

	e_signal_connect_notify (
		object, "notify::charset",
		G_CALLBACK (charset_combo_box_notify_charset_cb), NULL);
}
static void
empathy_mic_menu_add_microphone (EmpathyMicMenu *self,
    const gchar *name,
    const gchar *description,
    guint source_idx,
    gboolean is_monitor)
{
  EmpathyMicMenuPrivate *priv = self->priv;
  GtkRadioAction *action;
  GSList *group;

  action = gtk_radio_action_new (name, description, NULL, NULL, source_idx);
  gtk_action_group_add_action_with_accel (priv->action_group,
      GTK_ACTION (action), NULL);

  /* Set MONITOR_KEY on the action to non-NULL if it's a monitor
   * because we don't want to show monitors if we can help it. */
  if (is_monitor)
    {
      g_object_set_data (G_OBJECT (action), MONITOR_KEY,
          GUINT_TO_POINTER (TRUE));
    }

  group = gtk_radio_action_get_group (GTK_RADIO_ACTION (priv->anchor_action));
  gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);

  g_queue_push_tail (priv->microphones, action);

  g_signal_connect (action, "activate",
      G_CALLBACK (empathy_mic_menu_activate_cb), self);
}
Example #3
0
static GtkAction*
add_action (const GaleonEncodingInfo *info, GaleonEncodingMenu *menu)
{
	GtkAction *action;
	char name[128], *tooltip;

	g_snprintf (name, sizeof (name), "Encoding%s", info->encoding);
	tooltip = g_strdup_printf (_("Display the page using the \"%s\" encoding"),
				   info->encoding);

	action = g_object_new (GTK_TYPE_RADIO_ACTION,
			       "name", name,
			       "label", _(info->title),
			       "tooltip", tooltip,
			       NULL);

	gtk_radio_action_set_group (GTK_RADIO_ACTION (action),
				    menu->priv->encodings_radio_group);

	menu->priv->encodings_radio_group = gtk_radio_action_get_group
						(GTK_RADIO_ACTION (action));

	g_signal_connect (action, "activate",
			  G_CALLBACK (encoding_activate_cb),
			  menu);

	gtk_action_group_add_action (menu->priv->action_group, action);
	g_object_unref (action);
	g_free (tooltip);
	return action;
}
Example #4
0
static void
main_window_view_sort_contacts_cb (GtkRadioAction    *action,
				   GtkRadioAction    *current,
				   EmpathyMainWindow *window)
{
	EmpathyContactListStoreSort value;
	GSList      *group;
	GType        type;
	GEnumClass  *enum_class;
	GEnumValue  *enum_value;

	value = gtk_radio_action_get_current_value (action);
	group = gtk_radio_action_get_group (action);

	/* Get string from index */
	type = empathy_contact_list_store_sort_get_type ();
	enum_class = G_ENUM_CLASS (g_type_class_peek (type));
	enum_value = g_enum_get_value (enum_class, g_slist_index (group, current));

	if (!enum_value) {
		g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
			   g_slist_index (group, action));
	} else {
		empathy_conf_set_string (empathy_conf_get (),
					 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
					 enum_value->value_nick);
	}
	empathy_contact_list_store_set_sort_criterium (window->list_store, value);
}
Example #5
0
void
actions_radio_add(GtkActionGroup *act_group, const struct _actionhooks *ahs,
    int count)
{
	int i;
	GtkRadioAction *action;
	char *nel = malloc(max_path);
	GSList *list = NULL;

	for (i = 0; i < count; i++) {
		char *label = gettext(ahs[i].label);
		action = gtk_radio_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,
		  ahs[i].parameter);
		sprintf(nel, "<Actions>/actions/%s", ahs[i].name);
		gtk_action_set_accel_path(GTK_ACTION(action), nel);
		gtk_radio_action_set_group(action, list);
		list = gtk_radio_action_get_group(action);
		//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);
}
Example #6
0
static VALUE
raction_set_group(VALUE self, VALUE rbgroup)
{
    GtkRadioAction *action = _SELF(self);

    /* TODO: This might leak.  Use gtk_radio_action_join_group() in 3.0. */
    if (TYPE(rbgroup) == T_ARRAY)
        gtk_radio_action_set_group(action, RVAL2GTKRADIOACTIONGSLIST(rbgroup));
    else if (NIL_P(rbgroup))
        gtk_radio_action_set_group(action, NULL);
    else
        gtk_radio_action_set_group(action,
                                   gtk_radio_action_get_group(GTK_RADIO_ACTION(RVAL2GOBJ(rbgroup))));

    return self;
}
Example #7
0
static void
window_actions_display_closed (GdkDisplay      *display,
                               gboolean         is_error,
                               GimpActionGroup *group)
{
    const gchar *group_name;
    gint         n_screens;
    gint         i;

    group_name = gtk_action_group_get_name (GTK_ACTION_GROUP (group));

    n_screens = gdk_display_get_n_screens (display);

    for (i = 0; i < n_screens; i++)
    {
        GdkScreen *screen = gdk_display_get_screen (display, i);
        GtkAction *action;
        gchar     *screen_name;
        gchar     *action_name;

        screen_name = gdk_screen_make_display_name (screen);
        action_name = g_strdup_printf ("%s-move-to-screen-%s",
                                       group_name, screen_name);
        g_free (screen_name);

        action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                              action_name);

        if (action)
        {
            GSList *radio_group;

            radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
            if (radio_group->data == (gpointer) action)
                radio_group = radio_group->next;

            gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);

            g_object_set_data (G_OBJECT (group), "change-to-screen-radio-group",
                               radio_group);
        }

        g_free (action_name);
    }
}
Example #8
0
/* gtk_radio_action_set_current_value() replacement for GTK+ < 2.10 */
void radio_action_set_current_value(GtkRadioAction *action, gint current_value)
{
#if GTK_CHECK_VERSION(2, 10, 0)
    gtk_radio_action_set_current_value(action, current_value);
#else
    GSList *group;
    gint value;

    group = gtk_radio_action_get_group(action);
    while (group)
    {
        action = GTK_RADIO_ACTION(group->data);
        g_object_get(G_OBJECT(action), "value", &value, NULL);
        if (value == current_value)
        {
            gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
            return;
        }
        group = g_slist_next(group);
    }
#endif
}
void
e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view)
{
	ETaskShellContent *task_shell_content;
	EShellView *shell_view;
	EShellWindow *shell_window;
	EShellSearchbar *searchbar;
	EActionComboBox *combo_box;
	GtkActionGroup *action_group;
	GtkRadioAction *radio_action;
	GList *list, *iter;
	GSList *group;
	gint ii;

	shell_view = E_SHELL_VIEW (task_shell_view);
	shell_window = e_shell_view_get_shell_window (shell_view);

	action_group = ACTION_GROUP (TASKS_FILTER);
	e_action_group_remove_all_actions (action_group);

	/* Add the standard filter actions.  No callback is needed
	 * because changes in the EActionComboBox are detected and
	 * handled by EShellSearchbar. */
	gtk_action_group_add_radio_actions (
		action_group, task_filter_entries,
		G_N_ELEMENTS (task_filter_entries),
		TASK_FILTER_ANY_CATEGORY, NULL, NULL);

	/* Retrieve the radio group from an action we just added. */
	list = gtk_action_group_list_actions (action_group);
	radio_action = GTK_RADIO_ACTION (list->data);
	group = gtk_radio_action_get_group (radio_action);
	g_list_free (list);

	/* Build the category actions. */

	list = e_util_dup_searchable_categories ();
	for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
		const gchar *category_name = iter->data;
		gchar *filename;
		GtkAction *action;
		gchar *action_name;

		action_name = g_strdup_printf (
			"task-filter-category-%d", ii);
		radio_action = gtk_radio_action_new (
			action_name, category_name, NULL, NULL, ii);
		g_free (action_name);

		/* Convert the category icon file to a themed icon name. */
		filename = e_categories_dup_icon_file_for (category_name);
		if (filename != NULL && *filename != '\0') {
			gchar *basename;
			gchar *cp;

			basename = g_path_get_basename (filename);

			/* Lose the file extension. */
			if ((cp = strrchr (basename, '.')) != NULL)
				*cp = '\0';

			g_object_set (
				radio_action, "icon-name", basename, NULL);

			g_free (basename);
		}

		g_free (filename);

		gtk_radio_action_set_group (radio_action, group);
		group = gtk_radio_action_get_group (radio_action);

		/* The action group takes ownership of the action. */
		action = GTK_ACTION (radio_action);
		gtk_action_group_add_action (action_group, action);
		g_object_unref (radio_action);
	}
	g_list_free_full (list, g_free);

	task_shell_content = task_shell_view->priv->task_shell_content;
	searchbar = e_task_shell_content_get_searchbar (task_shell_content);
	combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);

	e_shell_view_block_execute_search (shell_view);

	/* Use any action in the group; doesn't matter which. */
	e_action_combo_box_set_action (combo_box, radio_action);

	ii = TASK_FILTER_UNMATCHED;
	e_action_combo_box_add_separator_after (combo_box, ii);

	ii = TASK_FILTER_TASKS_WITH_ATTACHMENTS;
	e_action_combo_box_add_separator_after (combo_box, ii);

	e_shell_view_unblock_execute_search (shell_view);
}
GtkWidget* create_tool_item( GtkAction* action )
{
    GtkWidget* item = 0;

    if ( IS_EGE_SELECT_ONE_ACTION(action) && EGE_SELECT_ONE_ACTION(action)->private_data->model )
    {
        EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(action);
        item = GTK_WIDGET( gtk_tool_item_new() );

        if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
#if GTK_CHECK_VERSION(3,0,0)
            GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
            gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
#else
            GtkWidget* holder = gtk_hbox_new( FALSE, 0 );
#endif

            GtkRadioAction* ract = 0;
            GSList* group = 0;
            GtkTreeIter iter;
            gboolean valid = FALSE;
            gint index = 0;

            {
                gchar*  sss = 0;
                g_object_get( G_OBJECT(action), "short_label", &sss, NULL );
                // If short_label not defined, g_object_get will return label.
                // This hack allows a label to be used with a drop-down menu when
                // no label is used with a set of icons that are self-explanatory.
                if (sss && strcmp( sss, "NotUsed" ) != 0 ) {
                    GtkWidget* lbl = gtk_label_new(sss);
                    gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
                }
                g_free( sss );
                sss = 0;
            }

            valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter );
            while ( valid ) {
                gchar* str = 0;
                gchar* tip = 0;
                gchar* iconId = 0;
                gboolean sens = true;
                /*
                gint size = 0;
                */
                gtk_tree_model_get( act->private_data->model, &iter,
                                    act->private_data->labelColumn, &str,
                                    -1 );
                if ( act->private_data->iconColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->iconColumn, &iconId,
                                        -1 );
                }
                if ( act->private_data->tooltipColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->tooltipColumn, &tip,
                                        -1 );
                }
                if ( act->private_data->sensitiveColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->sensitiveColumn, &sens,
                                        -1 );
                }

                if ( act->private_data->radioActionType ) {
                    void* obj = g_object_new( act->private_data->radioActionType,
                                              "name", "Name 1",
                                              "label", str,
                                              "tooltip", tip,
                                              "value", index,
                                              /*
                                              "iconId", iconId,
                                              "iconSize", size,
                                              */
                                              NULL );
                    if ( iconId ) {
                        g_object_set( G_OBJECT(obj), act->private_data->iconProperty, iconId, NULL );
                    }

                    if ( act->private_data->iconProperty ) {
                        /* TODO get this string to be set instead of hardcoded */
                        if ( act->private_data->iconSize >= 0 ) {
                            g_object_set( G_OBJECT(obj), "iconSize", act->private_data->iconSize, NULL );
                        }
                    }

                    ract = GTK_RADIO_ACTION(obj);
                } else {
                    ract = gtk_radio_action_new( "Name 1", str, tip, iconId, index );
                }

                if ( act->private_data->sensitiveColumn >= 0 ) {
                    gtk_action_set_sensitive( GTK_ACTION(ract), sens );
                }

                gtk_radio_action_set_group( ract, group );
                group = gtk_radio_action_get_group( ract );

                if ( index == act->private_data->active ) {
                    gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(ract), TRUE );
                }
                g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act );

                GtkWidget* sub = gtk_action_create_tool_item( GTK_ACTION(ract) );
                gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) );
                gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip );

                gtk_box_pack_start( GTK_BOX(holder), sub, FALSE, FALSE, 0 );

                g_free( str );
                g_free( tip );
                g_free( iconId );

                index++;
                valid = gtk_tree_model_iter_next( act->private_data->model, &iter );
            }

            g_object_set_data( G_OBJECT(holder), "ege-proxy_action-group", group );

            gtk_container_add( GTK_CONTAINER(item), holder );
        } else {
#if GTK_CHECK_VERSION(3,0,0)
            GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
            gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
#else
            GtkWidget *holder = gtk_hbox_new( FALSE, 4 );
#endif

            GtkEntry *entry = 0;
            GtkWidget *normal;

            if (act->private_data->selectionMode == SELECTION_OPEN) {
	            normal = gtk_combo_box_new_with_model_and_entry (act->private_data->model);
	            gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (normal), act->private_data->labelColumn);

                GtkWidget *child = gtk_bin_get_child( GTK_BIN(normal) );
                if (GTK_IS_ENTRY(child)) {
                    int maxUsed = scan_max_width( act->private_data->model, act->private_data->labelColumn );
                    GtkEntryCompletion *complete = 0;
                    entry = GTK_ENTRY(child);
                    gtk_entry_set_width_chars(entry, maxUsed); /* replace with property */

                    complete = gtk_entry_completion_new();
                    gtk_entry_completion_set_model( complete, act->private_data->model );
                    gtk_entry_completion_set_text_column( complete, act->private_data->labelColumn );
                    gtk_entry_completion_set_inline_completion( complete, FALSE );
                    gtk_entry_completion_set_inline_selection( complete, FALSE );
                    gtk_entry_completion_set_popup_completion( complete, TRUE );
                    gtk_entry_completion_set_popup_set_width( complete, FALSE );
                    gtk_entry_set_completion( entry, complete );

                    g_signal_connect( G_OBJECT(child), "activate", G_CALLBACK(combo_entry_changed_cb), act );
                    g_signal_connect( G_OBJECT(child), "focus-out-event", G_CALLBACK(combo_entry_focus_lost_cb), act );
                }
            } 
	    else {
                GtkCellRenderer * renderer = NULL;
                normal = gtk_combo_box_new_with_model( act->private_data->model );
                if ( act->private_data->iconColumn >= 0 ) {
                    renderer = gtk_cell_renderer_pixbuf_new();
                    gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );

                    /* "icon-name" */
                    gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "stock-id", act->private_data->iconColumn );
                }

                renderer = gtk_cell_renderer_text_new();
                gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );
                gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "text", act->private_data->labelColumn );
            }

            gtk_combo_box_set_active( GTK_COMBO_BOX(normal), act->private_data->active );
            if ( entry && (act->private_data->active == -1) ) {
                gtk_entry_set_text( entry, act->private_data->activeText );
            }

            g_signal_connect( G_OBJECT(normal), "changed", G_CALLBACK(combo_changed_cb), action );

            g_object_set_data( G_OBJECT(holder), "ege-combo-box", normal );
            g_object_set_data( G_OBJECT(act), "ege-combo-box", normal );

            if (act->private_data->appearanceMode == APPEARANCE_COMPACT) {
                gchar*  sss = 0;
                g_object_get( G_OBJECT(action), "short_label", &sss, NULL );
                if (sss) {
                    GtkWidget* lbl = gtk_label_new(sss);
                    gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
                    g_free( sss );
                    sss = 0;
                }
            }

            gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 );

            {
#if GTK_CHECK_VERSION(3,0,0)
                gtk_widget_set_halign(holder, GTK_ALIGN_START);
                gtk_container_add(GTK_CONTAINER(item), holder);
#else
                GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
                gtk_container_add( GTK_CONTAINER(align), holder);
                gtk_container_add( GTK_CONTAINER(item), align );
#endif
            }
        }

        gtk_widget_show_all( item );
    } else {
        item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action );
    }

    return item;
}
Example #11
0
GSList *
gimp_action_group_add_radio_actions (GimpActionGroup            *group,
                                     const gchar                *msg_context,
                                     const GimpRadioActionEntry *entries,
                                     guint                       n_entries,
                                     GSList                     *radio_group,
                                     gint                        value,
                                     GCallback                   callback)
{
  GtkRadioAction *first_action = NULL;
  gint            i;

  g_return_val_if_fail (GIMP_IS_ACTION_GROUP (group), NULL);

  for (i = 0; i < n_entries; i++)
    {
      GtkRadioAction *action;
      const gchar    *label;
      const gchar    *tooltip = NULL;

      if (! gimp_action_group_check_unique_action (group, entries[i].name))
        continue;

      if (msg_context)
        {
          label = g_dpgettext2 (NULL, msg_context, entries[i].label);

          if (entries[i].tooltip)
            tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
        }
      else
        {
          label   = gettext (entries[i].label);
          tooltip = gettext (entries[i].tooltip);
        }

      action = gimp_radio_action_new (entries[i].name, label, tooltip,
                                      entries[i].icon_name,
                                      entries[i].value);

      if (i == 0)
        first_action = action;

      gtk_radio_action_set_group (action, radio_group);
      radio_group = gtk_radio_action_get_group (action);

      if (value == entries[i].value)
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);

      gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
                                              GTK_ACTION (action),
                                              entries[i].accelerator);
      g_signal_emit (group, signals[ACTION_ADDED], 0, action);

      if (entries[i].help_id)
        g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
                                 g_strdup (entries[i].help_id),
                                 (GDestroyNotify) g_free);

      g_object_unref (action);
    }

  if (callback && first_action)
    g_signal_connect (first_action, "changed",
                      callback,
                      group->user_data);

  return radio_group;
}
Example #12
0
static void
action_combo_box_update_model (EActionComboBox *combo_box)
{
	GtkListStore *list_store;
	GSList *list;

	g_hash_table_remove_all (combo_box->priv->index);

	if (combo_box->priv->action == NULL) {
		gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), NULL);
		return;
	}

	/* We store values in the sort column as floats so that we can
	 * insert separators in between consecutive integer values and
	 * still maintain the proper ordering. */
	list_store = gtk_list_store_new (
		2, GTK_TYPE_RADIO_ACTION, G_TYPE_FLOAT);

	list = gtk_radio_action_get_group (combo_box->priv->action);
	combo_box->priv->group_has_icons = FALSE;

	while (list != NULL) {
		GtkTreeRowReference *reference;
		GtkRadioAction *action = list->data;
		GtkTreePath *path;
		GtkTreeIter iter;
		gchar *icon_name;
		gchar *stock_id;
		gint value;

		g_object_get (
			action, "icon-name", &icon_name,
			"stock-id", &stock_id, NULL);
		combo_box->priv->group_has_icons |=
			(icon_name != NULL || stock_id != NULL);
		g_free (icon_name);
		g_free (stock_id);

		gtk_list_store_append (list_store, &iter);
		g_object_get (action, "value", &value, NULL);
		gtk_list_store_set (
			list_store, &iter, COLUMN_ACTION,
			list->data, COLUMN_SORT, (gfloat) value, -1);

		path = gtk_tree_model_get_path (
			GTK_TREE_MODEL (list_store), &iter);
		reference = gtk_tree_row_reference_new (
			GTK_TREE_MODEL (list_store), path);
		g_hash_table_insert (
			combo_box->priv->index,
			GINT_TO_POINTER (value), reference);
		gtk_tree_path_free (path);

		list = g_slist_next (list);
	}

	gtk_tree_sortable_set_sort_column_id (
		GTK_TREE_SORTABLE (list_store),
		COLUMN_SORT, GTK_SORT_ASCENDING);
	gtk_combo_box_set_model (
		GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store));

	action_combo_box_action_changed_cb (
		combo_box->priv->action,
		combo_box->priv->action,
		combo_box);
}
Example #13
0
static void
anjuta_docman_update_documents_menu (AnjutaDocman* docman)
{
	AnjutaDocmanPriv *priv = docman->priv;
	GtkUIManager* ui = GTK_UI_MANAGER (anjuta_shell_get_ui (ANJUTA_PLUGIN (priv->plugin)->shell,
															NULL));
	GList *actions, *l;
	gint n, i;
	guint id;
	GSList *group = NULL;

	g_return_if_fail (priv->documents_action_group != NULL);

	if (priv->documents_merge_id != 0)
		gtk_ui_manager_remove_ui (ui,
					  priv->documents_merge_id);

	actions = gtk_action_group_list_actions (priv->documents_action_group);
	for (l = actions; l != NULL; l = l->next)
	{
		g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
						      G_CALLBACK (on_document_toggled),
						      docman);
 		gtk_action_group_remove_action (priv->documents_action_group,
						GTK_ACTION (l->data));
	}
	g_list_free (actions);

	n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (docman));

	id = (n > 0) ? gtk_ui_manager_new_merge_id (ui) : 0;

	for (i = 0; i < n; i++)
	{
		AnjutaDocmanPage* page;
		GtkRadioAction *action;
		gchar *action_name;
		const gchar *tab_name;
		gchar *accel;

		page = anjuta_docman_get_nth_page (docman, i);

		/* NOTE: the action is associated to the position of the tab in
		 * the notebook not to the tab itself! This is needed to work
		 * around the gtk+ bug #170727: gtk leaves around the accels
		 * of the action. Since the accel depends on the tab position
		 * the problem is worked around, action with the same name always
		 * get the same accel.
		 */
		action_name = g_strdup_printf ("Tab_%d", i);
		tab_name = gtk_label_get_label (GTK_LABEL (page->label));

		/* alt + 1, 2, 3... 0 to switch to the first ten tabs */
		accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;

		action = gtk_radio_action_new (action_name,
					       tab_name,
					       NULL,
					       NULL,
					       i);

		if (group != NULL)
			gtk_radio_action_set_group (action, group);

		/* note that group changes each time we add an action, so it must be updated */
		group = gtk_radio_action_get_group (action);

		gtk_action_group_add_action_with_accel (priv->documents_action_group,
							GTK_ACTION (action),
							accel);

		g_signal_connect (action,
				  "toggled",
				  G_CALLBACK (on_document_toggled),
				  docman);

		gtk_ui_manager_add_ui (ui,
				       id,
				       MENU_PLACEHOLDER,
				       action_name, action_name,
				       GTK_UI_MANAGER_MENUITEM,
				       FALSE);

		if (i == gtk_notebook_get_current_page (GTK_NOTEBOOK (docman)))
			gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);

		g_object_unref (action);

		g_free (action_name);
		g_free (accel);
	}
	anjuta_docman_update_documents_menu_status (docman);
	priv->documents_merge_id = id;
}
Example #14
0
static VALUE
raction_get_group(VALUE self)
{
    /* Owned by GTK+ */
    return GSLIST2ARY(gtk_radio_action_get_group(_SELF(self)));
}