예제 #1
0
void
gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
                              glWindow        *window)
{
        gboolean     state;

        gl_debug (DEBUG_COMMANDS, "START");

        g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
        g_return_if_fail (window && GL_IS_WINDOW(window));

        state =  gtk_toggle_action_get_active (action);

        if (window->view != NULL)
        {
                if (state) {
                        gl_view_show_markup (GL_VIEW(window->view));
                } else {
                        gl_view_hide_markup (GL_VIEW(window->view));
                }
        }

        gl_prefs_model_set_markup_visible (gl_prefs, state);

        gl_debug (DEBUG_COMMANDS, "END");
}
예제 #2
0
파일: gtktoggleaction.c 프로젝트: GYGit/gtk
/**
 * gtk_toggle_action_get_draw_as_radio:
 * @action: the action object
 *
 * Returns whether the action should have proxies like a radio action.
 *
 * Returns: whether the action should have proxies like a radio action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10
 */
gboolean
gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action)
{
  g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);

  return action->private_data->draw_as_radio;
}
예제 #3
0
void
gimp_action_group_set_action_active (GimpActionGroup *group,
                                     const gchar     *action_name,
                                     gboolean         active)
{
  GtkAction *action;

  g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
  g_return_if_fail (action_name != NULL);

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

  if (! action)
    {
      g_warning ("%s: Unable to set \"active\" of action "
                 "which doesn't exist: %s",
                 G_STRFUNC, action_name);
      return;
    }

  if (! GTK_IS_TOGGLE_ACTION (action))
    {
      g_warning ("%s: Unable to set \"active\" of action "
                 "which is not a GtkToggleAction: %s",
                 G_STRFUNC, action_name);
      return;
    }

  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
                                active ? TRUE : FALSE);
}
예제 #4
0
static void
update_bindings (AthenaNavigationState *self)
{
    gint length, idx;
    GBinding *binding;
    GtkAction *master_action, *slave_action;

    length = g_strv_length (self->priv->action_names);

    for (idx = 0; idx < length; idx++) {
        master_action = gtk_action_group_get_action (self->priv->master,
                        self->priv->action_names[idx]);
        slave_action = gtk_action_group_get_action (self->priv->slave,
                       self->priv->action_names[idx]);
        binding = g_object_bind_property (master_action, "sensitive",
                                          slave_action, "sensitive",
                                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

        /* bind "active" too for toggle actions */
        if (GTK_IS_TOGGLE_ACTION (master_action)) {
            binding = g_object_bind_property (master_action, "active",
                                              slave_action, "active",
                                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
        }

        self->priv->active_bindings = g_list_prepend (self->priv->active_bindings, binding);
    }
}
예제 #5
0
파일: ui.c 프로젝트: samlown/glabels
/*---------------------------------------------------------------------------*/
static void
view_ui_item_toggled_cb (GtkToggleAction *action,
			 GtkUIManager    *ui)
{
	const gchar *name;
	gboolean     state;

	gl_debug (DEBUG_UI, "START");

	g_return_if_fail (action && GTK_IS_TOGGLE_ACTION (action));

	name  = gtk_action_get_name (GTK_ACTION (action));
	state = gtk_toggle_action_get_active (action);

	gl_debug (DEBUG_UI, "Action = %s, State = %d", name, state);

	if (strcmp (name, "ViewMainToolBar") == 0)
	{
                gl_prefs_model_set_main_toolbar_visible (gl_prefs, state);
		set_app_main_toolbar_style (ui);
	}

	if (strcmp (name, "ViewDrawingToolBar") == 0)
	{
		gl_prefs_model_set_drawing_toolbar_visible (gl_prefs, state);
		set_app_drawing_toolbar_style (ui);
	}

	gl_debug (DEBUG_UI, "");
}
예제 #6
0
파일: gtktoggleaction.c 프로젝트: GYGit/gtk
/**
 * gtk_toggle_action_toggled:
 * @action: the action object
 *
 * Emits the “toggled” signal on the toggle action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10
 */
void
gtk_toggle_action_toggled (GtkToggleAction *action)
{
  g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));

  g_signal_emit (action, action_signals[TOGGLED], 0);
}
예제 #7
0
static void
gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
                                            GtkAction      *action)
{
  GtkCheckMenuItem *check_menu_item;
  gboolean use_action_appearance;
  gboolean is_toggle_action;

  check_menu_item = GTK_CHECK_MENU_ITEM (activatable);

  parent_activatable_iface->sync_action_properties (activatable, action);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  is_toggle_action = GTK_IS_TOGGLE_ACTION (action);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  if (!is_toggle_action)
    return;

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  gtk_action_block_activate (action);

  gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
  gtk_action_unblock_activate (action);
  use_action_appearance = gtk_activatable_get_use_action_appearance (activatable);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  if (!use_action_appearance)
    return;

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  gtk_check_menu_item_set_draw_as_radio (check_menu_item,
                                         gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
  G_GNUC_END_IGNORE_DEPRECATIONS;
}
static void contextMenuItemActivatedCallback(GtkAction* action, WebPageProxy* page)
{
    gboolean isToggle = GTK_IS_TOGGLE_ACTION(action);
    WebKit::WebContextMenuItemData item(isToggle ? WebCore::CheckableActionType : WebCore::ActionType,
        static_cast<WebCore::ContextMenuAction>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), gContextMenuActionId))),
        String::fromUTF8(gtk_action_get_label(action)), gtk_action_get_sensitive(action),
        isToggle ? gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) : false);
    page->contextMenuItemSelected(item);
}
예제 #9
0
파일: gtktoggleaction.c 프로젝트: GYGit/gtk
/**
 * gtk_toggle_action_set_active:
 * @action: the action object
 * @is_active: whether the action should be checked or not
 *
 * Sets the checked state on the toggle action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10
 */
void
gtk_toggle_action_set_active (GtkToggleAction *action, 
			      gboolean         is_active)
{
  g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));

  is_active = is_active != FALSE;

  if (action->private_data->active != is_active)
    _gtk_action_emit_activate (GTK_ACTION (action));
}
예제 #10
0
파일: main.c 프로젝트: Comthit/workrave
void on_menu_changed(gpointer instance, GVariant *parameters, gpointer user_data)
{
  WorkraveApplet *applet = (WorkraveApplet *)user_data;
  applet->inhibit++;

  GVariantIter *iter;
  g_variant_get (parameters, "(a(sii))", &iter);

  char *text;
  int id;
  int flags;

  gboolean visible[sizeof(menu_data)/sizeof(struct Menuitems)];
  for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
    {
      visible[i] = menu_data[i].visible_when_not_running;
    }

  while (g_variant_iter_loop(iter, "(sii)", &text, &id, &flags))
    {
      int index = lookup_menu_index_by_id((enum MenuCommand)id);
      if (index == -1)
        {
          continue;
        }

      GtkAction *action = gtk_action_group_get_action(applet->action_group, menu_data[index].action);

      if (flags & MENU_ITEM_FLAG_SUBMENU_END ||
          flags & MENU_ITEM_FLAG_SUBMENU_BEGIN)
        {
          continue;
        }

      visible[index] = TRUE;

      if (GTK_IS_TOGGLE_ACTION(action))
        {
          GtkToggleAction *toggle = GTK_TOGGLE_ACTION(action);
          gtk_toggle_action_set_active(toggle, flags & MENU_ITEM_FLAG_ACTIVE);
        }
    }

  g_variant_iter_free (iter);

  for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
    {
      GtkAction *action = gtk_action_group_get_action(applet->action_group, menu_data[i].action);
      gtk_action_set_visible(action, visible[i]);
    }
  applet->inhibit--;
}
예제 #11
0
int
clip_GTK_TOGGLEACTIONTOGGLED(ClipMachine * cm)
{
    C_object *caction   = _fetch_co_arg(cm);

    CHECKARG2(1,MAP_t, NUMERIC_t);
    CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));

    gtk_toggle_action_toggled(GTK_TOGGLE_ACTION(caction->object));

    return 0;
err:
    return 1;
}
예제 #12
0
int
clip_GTK_TOGGLEACTIONTOGGLED(ClipMachine * ClipMachineMemory)
{
   C_object *caction = _fetch_co_arg(ClipMachineMemory);

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));

   gtk_toggle_action_toggled(GTK_TOGGLE_ACTION(caction->object));

   return 0;
 err:
   return 1;
}
예제 #13
0
int
clip_GTK_TOGGLEACTIONGETDRAWASRADIO(ClipMachine * cm)
{
    C_object *caction   = _fetch_co_arg(cm);

    CHECKARG2(1,MAP_t, NUMERIC_t);
    CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));

    _clip_retl(cm, gtk_toggle_action_get_draw_as_radio(GTK_TOGGLE_ACTION(caction->object)));

    return 0;
err:
    return 1;
}
예제 #14
0
int
clip_GTK_TOGGLEACTIONGETDRAWASRADIO(ClipMachine * ClipMachineMemory)
{
   C_object *caction = _fetch_co_arg(ClipMachineMemory);

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));

   _clip_retl(ClipMachineMemory, gtk_toggle_action_get_draw_as_radio(GTK_TOGGLE_ACTION(caction->object)));

   return 0;
 err:
   return 1;
}
예제 #15
0
파일: gtktoggleaction.c 프로젝트: GYGit/gtk
/**
 * gtk_toggle_action_set_draw_as_radio:
 * @action: the action object
 * @draw_as_radio: whether the action should have proxies like a radio 
 *    action
 *
 * Sets whether the action should have proxies like a radio action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10
 */
void
gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action, 
				     gboolean         draw_as_radio)
{
  g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));

  draw_as_radio = draw_as_radio != FALSE;

  if (action->private_data->draw_as_radio != draw_as_radio)
    {
      action->private_data->draw_as_radio = draw_as_radio;
      
      g_object_notify (G_OBJECT (action), "draw-as-radio");      
    }
}
예제 #16
0
파일: gtktoggleaction.c 프로젝트: GYGit/gtk
static void
gtk_toggle_action_activate (GtkAction *action)
{
  GtkToggleAction *toggle_action;

  g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));

  toggle_action = GTK_TOGGLE_ACTION (action);

  toggle_action->private_data->active = !toggle_action->private_data->active;

  g_object_notify (G_OBJECT (action), "active");

  gtk_toggle_action_toggled (toggle_action);
}
예제 #17
0
int
clip_GTK_TOGGLEACTIONSETDRAWASRADIO(ClipMachine * cm)
{
    C_object *caction   = _fetch_co_arg(cm);
    gboolean draw_as_radio = _clip_parl(cm, 2);

    CHECKARG2(1,MAP_t, NUMERIC_t);
    CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));
    CHECKARG(2, LOGICAL_t);

    gtk_toggle_action_set_draw_as_radio(GTK_TOGGLE_ACTION(caction->object), draw_as_radio);

    return 0;
err:
    return 1;
}
예제 #18
0
int
clip_GTK_TOGGLEACTIONSETACTIVE(ClipMachine * cm)
{
    C_object *caction   = _fetch_co_arg(cm);
    gboolean is_active  = _clip_parl(cm, 2);

    CHECKARG2(1,MAP_t, NUMERIC_t);
    CHECKCOBJ(caction, GTK_IS_TOGGLE_ACTION(caction->object));
    CHECKARG(2, LOGICAL_t);

    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(caction->object), is_active);

    return 0;
err:
    return 1;
}
예제 #19
0
static void
gtk_toggle_tool_button_sync_action_properties (GtkActivatable *activatable,
					       GtkAction      *action)
{
  GtkToggleToolButton *button;

  parent_activatable_iface->sync_action_properties (activatable, action);

  if (!GTK_IS_TOGGLE_ACTION (action))
    return;

  button = GTK_TOGGLE_TOOL_BUTTON (activatable);

  gtk_action_block_activate (action);
  gtk_toggle_tool_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
  gtk_action_unblock_activate (action);
}
예제 #20
0
    void checkActionState(GtkAction* action, unsigned state)
    {
        if (state & Visible)
            g_assert(gtk_action_get_visible(action));
        else
            g_assert(!gtk_action_get_visible(action));

        if (state & Enabled)
            g_assert(gtk_action_get_sensitive(action));
        else
            g_assert(!gtk_action_get_sensitive(action));

        if (GTK_IS_TOGGLE_ACTION(action)) {
            if (state & Checked)
                g_assert(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
            else
                g_assert(!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
        }
    }
예제 #21
0
void
gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action,
                                    glWindow        *window)
{
        gboolean     state;

        gl_debug (DEBUG_COMMANDS, "START");

        g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
        g_return_if_fail (window && GL_IS_WINDOW(window));

        state =  gtk_toggle_action_get_active (action);

        gl_prefs_model_set_property_toolbar_visible (gl_prefs, state);
        if (state) {
                gtk_widget_show (GTK_WIDGET (window->property_bar));
        } else {
                gtk_widget_hide (GTK_WIDGET (window->property_bar));
        }

        gl_debug (DEBUG_COMMANDS, "END");
}
예제 #22
0
static void
gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
                                            GtkAction      *action)
{
  GtkCheckMenuItem *check_menu_item;

  check_menu_item = GTK_CHECK_MENU_ITEM (activatable);

  parent_activatable_iface->sync_action_properties (activatable, action);

  if (!GTK_IS_TOGGLE_ACTION (action))
    return;

  gtk_action_block_activate (action);
  gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
  gtk_action_unblock_activate (action);
  
  if (!gtk_activatable_get_use_action_appearance (activatable))
    return;

  gtk_check_menu_item_set_draw_as_radio (check_menu_item,
                                         gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
}
예제 #23
0
static void
gtk_toggle_tool_button_sync_action_properties (GtkActivatable *activatable,
					       GtkAction      *action)
{
  GtkToggleToolButton *button;
  gboolean is_toggle_action;

  parent_activatable_iface->sync_action_properties (activatable, action);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  is_toggle_action = GTK_IS_TOGGLE_ACTION (action);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  if (!is_toggle_action)
    return;

  button = GTK_TOGGLE_TOOL_BUTTON (activatable);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  gtk_action_block_activate (action);
  gtk_toggle_tool_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
  gtk_action_unblock_activate (action);
  G_GNUC_END_IGNORE_DEPRECATIONS;
}
예제 #24
0
GtkWidget *
gimp_editor_add_action_button (GimpEditor  *editor,
                               const gchar *group_name,
                               const gchar *action_name,
                               ...)
{
  GimpActionGroup *group;
  GtkAction       *action;
  GtkWidget       *button;
  GtkWidget       *old_child;
  GtkWidget       *image;
  GtkIconSize      button_icon_size;
  GtkReliefStyle   button_relief;
  const gchar     *stock_id;
  gchar           *tooltip;
  const gchar     *help_id;
  GList           *extended = NULL;
  va_list          args;

  g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL);
  g_return_val_if_fail (action_name != NULL, NULL);
  g_return_val_if_fail (editor->ui_manager != NULL, NULL);

  group = gimp_ui_manager_get_action_group (editor->ui_manager, group_name);

  g_return_val_if_fail (group != NULL, NULL);

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

  g_return_val_if_fail (action != NULL, NULL);

  button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief);

  if (GTK_IS_TOGGLE_ACTION (action))
    button = gtk_toggle_button_new ();
  else
    button = gimp_button_new ();

  gtk_button_set_relief (GTK_BUTTON (button), button_relief);

  stock_id = gtk_action_get_stock_id (action);
  tooltip  = g_strdup (gtk_action_get_tooltip (action));

  old_child = gtk_bin_get_child (GTK_BIN (button));

  if (old_child)
    gtk_container_remove (GTK_CONTAINER (button), old_child);

  image = gtk_image_new_from_stock (stock_id, button_icon_size);
  gtk_container_add (GTK_CONTAINER (button), image);
  gtk_widget_show (image);

  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
  gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  va_start (args, action_name);

  action_name = va_arg (args, const gchar *);

  while (action_name)
    {
      GdkModifierType mod_mask;

      mod_mask = va_arg (args, GdkModifierType);

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

      if (action && mod_mask)
        {
          ExtendedAction *ext = g_slice_new (ExtendedAction);

          ext->mod_mask = mod_mask;
          ext->action   = action;

          extended = g_list_prepend (extended, ext);

          if (tooltip)
            {
              const gchar *ext_tooltip = gtk_action_get_tooltip (action);

              if (ext_tooltip)
                {
                  gchar *tmp = g_strconcat (tooltip, "\n<b>",
                                            gimp_get_mod_string (mod_mask),
                                            "</b>  ", ext_tooltip, NULL);
                  g_free (tooltip);
                  tooltip = tmp;
                }
            }
        }

      action_name = va_arg (args, const gchar *);
    }

  va_end (args);

  if (extended)
    {
      g_object_set_data_full (G_OBJECT (button), "extended-actions", extended,
                              (GDestroyNotify) gimp_editor_button_extended_actions_free);

      g_signal_connect (button, "extended-clicked",
                        G_CALLBACK (gimp_editor_button_extended_clicked),
                        NULL);
    }

  help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);

  if (tooltip || help_id)
    gimp_help_set_help_data_with_markup (button, tooltip, help_id);

  g_free (tooltip);

  return button;
}