예제 #1
0
int
clip_GTK_ACTIONGROUPTRANSLATESTRING(ClipMachine * ClipMachineMemory)
{
   C_object *cagroup = _fetch_co_arg(ClipMachineMemory);

   gchar    *string = _clip_parc(ClipMachineMemory, 2);

   gchar    *resstr;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cagroup, GTK_IS_ACTION_GROUP(cagroup->object));
   CHECKARG(2, CHARACTER_type_of_ClipVarType);

   LOCALE_TO_UTF(string);
   resstr = (gchar *) gtk_action_group_translate_string(GTK_ACTION_GROUP(cagroup->object), string);
   LOCALE_FROM_UTF(resstr);
   _clip_retc(ClipMachineMemory, resstr);

   FREE_TEXT(string);
   FREE_TEXT(resstr);

   return 0;
 err:
   return 1;
}
예제 #2
0
/**
 * _rb_action_group_add_source_actions:
 * @group: a #GtkActionGroup
 * @shell: the #RBShell
 * @actions: array of GtkActionEntry structures for the action group
 * @num_actions: number of actions in the @actions array
 *
 * Adds actions to an action group where the action callback is
 * called with the current selected source.  This can safely be called
 * multiple times on the same action group.
 */
void
_rb_action_group_add_source_actions (GtkActionGroup *group,
				     GObject *shell,
				     GtkActionEntry *actions,
				     int num_actions)
{
	int i;
	for (i = 0; i < num_actions; i++) {
		GtkAction *action;
		const char *label;
		const char *tooltip;
		SourceActionData *source_action_data;

		if (gtk_action_group_get_action (group, actions[i].name) != NULL) {
			/* action was already added */
			continue;
		}

		label = gtk_action_group_translate_string (group, actions[i].label);
		tooltip = gtk_action_group_translate_string (group, actions[i].tooltip);

		action = gtk_action_new (actions[i].name, label, tooltip, NULL);
		if (actions[i].stock_id != NULL) {
			g_object_set (action, "stock-id", actions[i].stock_id, NULL);
			if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
						     actions[i].stock_id)) {
				g_object_set (action, "icon-name", actions[i].stock_id, NULL);
			}
		}

		if (actions[i].callback) {
			GClosure *closure;
			source_action_data = g_slice_new0 (SourceActionData);
			source_action_data->callback = (SourceActionCallback) actions[i].callback;
			source_action_data->shell = shell;
			g_object_add_weak_pointer (shell, &source_action_data->shell);

			closure = g_cclosure_new (G_CALLBACK (source_action_cb),
						  source_action_data,
						  (GClosureNotify) source_action_data_destroy);
			g_signal_connect_closure (action, "activate", closure, FALSE);
		}

		gtk_action_group_add_action_with_accel (group, action, actions[i].accelerator);
		g_object_unref (action);
	}
}
예제 #3
0
static VALUE
rg_translate_string(VALUE self, VALUE str)
{
    return CSTR2RVAL(gtk_action_group_translate_string(_SELF(self), RVAL2CSTR(str)));
}