Esempio n. 1
0
int
clip_GTK_ACTIONGROUPADDTOGGLEACTIONSFULL(ClipMachine * ClipMachineMemory)
{
   C_object *cagroup = _fetch_co_arg(ClipMachineMemory);

   ClipArrVar *carr = (ClipArrVar *) _clip_vptr(_clip_spar(ClipMachineMemory, 2));

   guint     n_actions = _clip_parni(ClipMachineMemory, 3);

   ClipVar  *cfunc = _clip_spar(ClipMachineMemory, 4);

   C_var    *c = NEW(C_var);

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cagroup, GTK_IS_ACTION_GROUP(cagroup->object));
   CHECKARG(2, ARRAY_type_of_ClipVarType);
   CHECKARG(3, NUMERIC_type_of_ClipVarType);
   CHECKARG2(4, PCODE_type_of_ClipVarType, CCODE_type_of_ClipVarType);

   if (carr)
    {
       GtkToggleActionEntry *acts;

       gint      i;

       acts = malloc(carr->count_of_ClipArrVar * sizeof(GtkToggleActionEntry));
       memset(acts, 0, sizeof(GtkToggleActionEntry) * carr->count_of_ClipArrVar);
       for (i = 0; i < n_actions; i++)
	  _map_to_toggle_action_entry(ClipMachineMemory, &carr->ClipVar_items_of_ClipArrVar[i], &acts[i]);

       c->ClipMachineMemory = ClipMachineMemory;
       c->co = cagroup;
       _clip_mclone(ClipMachineMemory, &c->cfunc2, cfunc);
       gtk_action_group_add_toggle_actions_full(GTK_ACTION_GROUP
						(cagroup->object), acts, n_actions, c, (GDestroyNotify) destroy_d);
       free(acts);
    }

   return 0;
 err:
   return 1;
}
static void
impl_activate (PlumaPlugin *plugin,
	       PlumaWindow *window)
{
	PlumaDrawspacesPlugin *ds_plugin;
	GtkUIManager *manager;
	GError *error = NULL;
	GtkAction *action;
	WindowData *data;
	ActionData *action_data;

	pluma_debug (DEBUG_PLUGINS);

	ds_plugin = PLUMA_DRAWSPACES_PLUGIN (plugin);

	data = g_slice_new (WindowData);
	action_data = g_slice_new (ActionData);

	action_data->window = window;
	action_data->plugin = ds_plugin;

	get_config_options (data, ds_plugin);

	manager = pluma_window_get_ui_manager (window);

	data->action_group = gtk_action_group_new ("PlumaDrawspacesPluginActions");
	gtk_action_group_set_translation_domain (data->action_group,
						 GETTEXT_PACKAGE);
	gtk_action_group_add_toggle_actions_full (data->action_group,
						  action_entries,
						  G_N_ELEMENTS (action_entries),
						  action_data,
						  (GDestroyNotify) free_action_data);

	/* Lets set the default value */
	action = gtk_action_group_get_action (data->action_group,
					      "DrawSpaces");
	g_signal_handlers_block_by_func (action, on_active_toggled, action_data);
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
				      data->enable);
	g_signal_handlers_unblock_by_func (action, on_active_toggled, action_data);

	gtk_ui_manager_insert_action_group (manager, data->action_group, -1);

	data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
							 submenu,
							 -1,
							 &error);
	if (error)
	{
		g_warning ("%s", error->message);
		g_error_free (error);
	}

	g_object_set_data_full (G_OBJECT (window),
				WINDOW_DATA_KEY,
				data,
				(GDestroyNotify) free_window_data);

	if (data->enable)
	{
		draw_spaces_in_window (window, ds_plugin);
	}

	g_signal_connect (window, "tab-added",
			  G_CALLBACK (tab_added_cb), ds_plugin);
}