Beispiel #1
0
void
glade_gtk_menu_item_action_activate (GladeWidgetAdaptor * adaptor,
                                     GObject * object,
                                     const gchar * action_path)
{
  GObject *obj = NULL, *shell = NULL;
  GladeWidget *w = glade_widget_get_from_gobject (object);

  while ((w = glade_widget_get_parent (w)))
    {
      obj = glade_widget_get_object (w);
      if (GTK_IS_MENU_SHELL (obj))
        shell = obj;
    }

  if (strcmp (action_path, "launch_editor") == 0)
    {
      if (shell)
        object = shell;

      if (GTK_IS_MENU_BAR (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
      else if (GTK_IS_MENU (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
    }
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
                                                         object, action_path);

  if (shell)
    gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell));
}
Beispiel #2
0
static void
panel_applet_recreate_menu (AppletInfo *info)
{
	if (info->menu) {
		GList *l;

		for (l = info->user_menu; l; l = l->next) {
			AppletUserMenu *menu = l->data;

			menu->menuitem = NULL;
			menu->submenu = NULL;
		}

		if (gtk_widget_get_visible (info->menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (info->menu));

		g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_show), info);
		g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_deactivate), info);

		g_object_unref (info->menu);
		info->menu = NULL;
	}

	panel_applet_get_menu (info);
}
Beispiel #3
0
int
clip_GTK_MENUSHELLDEACTIVATE(ClipMachine * cm)
{
	C_widget *cmns = _fetch_cw_arg(cm);
        CHECKCWID(cmns,GTK_IS_MENU_SHELL);
        gtk_menu_shell_deactivate(GTK_MENU_SHELL(cmns->widget));
	return 0;
err:
	return 1;
}
Beispiel #4
0
static void
panel_applet_destroy (GtkWidget  *widget,
		      AppletInfo *info)
{
	GList *l;

	g_return_if_fail (info != NULL);

	info->widget = NULL;

	registered_applets = g_slist_remove (registered_applets, info);

	queued_position_saves =
		g_slist_remove (queued_position_saves, info);

	if (info->menu) {
		if (gtk_widget_get_visible (info->menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (info->menu));

                g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_show), info);
                g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_deactivate), info);
		g_object_unref (info->menu);
        }
	info->menu = NULL;


	if (info->data_destroy)
		info->data_destroy (info->data);
	info->data = NULL;

	for (l = info->user_menu; l != NULL; l = l->next) {
		AppletUserMenu *umenu = l->data;

		g_free (umenu->name);
		g_free (umenu->stock_item);
		g_free (umenu->text);

		g_free (umenu);
	}

	g_list_free (info->user_menu);
	info->user_menu = NULL;

	if (info->settings)
		g_object_unref (info->settings);
	info->settings = NULL;

	g_free (info->id);
	info->id = NULL;

	g_free (info);
}
Beispiel #5
0
static void
menu_item_toggled_cb(GtkCheckMenuItem * item, toolbar_info * info)
{
    if (gtk_check_menu_item_get_active(item)) {
        info->model->style =
            GPOINTER_TO_INT(g_object_get_data
                            (G_OBJECT(item), BALSA_TOOLBAR_STYLE));
        balsa_toolbar_model_changed(info->model);
        if (info->menu)
            gtk_menu_shell_deactivate(GTK_MENU_SHELL(info->menu));
    }
}
Beispiel #6
0
static gboolean
gear_menu_key_press (GtkWidget *widget,
                     GdkEventKey *event,
                     gpointer user_data)
{
        GdkModifierType mask = gtk_accelerator_get_default_mod_mask ();

        if ((event->state & mask) == 0 && (event->keyval == GDK_KEY_F10)) {
            gtk_menu_shell_deactivate (GTK_MENU_SHELL (widget));
            return TRUE;
        }

        return FALSE;
}
Beispiel #7
0
static void
gtk_menu_button_state_flags_changed (GtkWidget    *widget,
                                     GtkStateFlags previous_state_flags)
{
  GtkMenuButton *button = GTK_MENU_BUTTON (widget);
  GtkMenuButtonPrivate *priv = button->priv;

  if (!gtk_widget_is_sensitive (widget))
    {
      if (priv->menu)
        gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
      else if (priv->popover)
        gtk_widget_hide (priv->popover);
    }
}
Beispiel #8
0
/* This function is used in GtkMenuToolButton, the call back will
 * be called when GtkMenuToolButton would have emitted the “show-menu”
 * signal.
 */
void
_gtk_menu_button_set_popup_with_func (GtkMenuButton                 *menu_button,
                                      GtkWidget                     *menu,
                                      GtkMenuButtonShowMenuCallback  func,
                                      gpointer                       user_data)
{
  GtkMenuButtonPrivate *priv;

  g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
  g_return_if_fail (GTK_IS_MENU (menu) || menu == NULL);

  priv = menu_button->priv;
  priv->func = func;
  priv->user_data = user_data;

  if (priv->menu == GTK_WIDGET (menu))
    return;

  if (priv->menu)
    {
      if (gtk_widget_get_visible (priv->menu))
        gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));

      g_signal_handlers_disconnect_by_func (priv->menu,
                                            menu_deactivate_cb,
                                            menu_button);
      gtk_menu_detach (GTK_MENU (priv->menu));
    }

  priv->menu = menu;

  if (priv->menu)
    {
      gtk_menu_attach_to_widget (GTK_MENU (priv->menu), GTK_WIDGET (menu_button),
                                 menu_detacher);

      gtk_widget_set_visible (priv->menu, FALSE);

      g_signal_connect_swapped (priv->menu, "deactivate",
                                G_CALLBACK (menu_deactivate_cb), menu_button);
      gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (menu_button)), "menu-button");
    }

  update_sensitivity (menu_button);

  g_object_notify (G_OBJECT (menu_button), "popup");
  g_object_notify (G_OBJECT (menu_button), "menu-model");
}
Beispiel #9
0
static void
panel_menu_lockdown_changed (PanelLockdown *lockdown,
			     gpointer       user_data)
{
	PanelData *pd = user_data;

	if (pd->menu) {
		if (gtk_widget_get_visible (pd->menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (pd->menu));

		g_signal_handlers_disconnect_by_func (pd->menu,
						      context_menu_deactivate,
						      pd);

		g_object_unref (pd->menu);
		pd->menu = NULL;
	}
}
static gboolean
hn_others_menu_key_press(GtkWidget *menu,
			 GdkEventKey *event,
			 HNOthersButton *button)
{
  gboolean cancel_menu = FALSE;
  HDWM *hdwm = hd_wm_get_singleton ();

  if (gtk_widget_get_direction (menu) == GTK_TEXT_DIR_RTL)
  {
    if (event->keyval == GDK_Right    ||
        event->keyval == GDK_KP_Right)
      cancel_menu = TRUE;
  } else
  {
    if (event->keyval == GDK_Left    ||
        event->keyval == GDK_KP_Left)
      cancel_menu = TRUE;
  }

  if (cancel_menu ||
      event->keyval == GDK_Escape)
  {
    gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu));

    if (event->keyval == GDK_Escape)
    {
      /* pass focus to the last active application */
      hd_wm_focus_active_window (hdwm);
    }
    else
    {
      GdkWindow *window = gtk_widget_get_parent_window (button->priv->button);
     
      gtk_widget_grab_focus (GTK_WIDGET (button->priv->button));
      hd_wm_activate_window (HD_TN_ACTIVATE_KEY_FOCUS,window);
    }
    
    return TRUE;
  }

  return FALSE;
}
Beispiel #11
0
static void
panel_applet_edit_menu_lockdown_changed (PanelLockdown *lockdown,
					 gpointer       user_data)
{
	AppletInfo *info = user_data;

	if (!panel_lockdown_get_panels_locked_down (lockdown))
		return;

	if (info->edit_menu) {
		if (gtk_widget_get_visible (info->edit_menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (info->edit_menu));

                g_signal_handlers_disconnect_by_func (info->edit_menu,
						      G_CALLBACK (applet_menu_deactivate), info);
		gtk_widget_destroy (info->edit_menu);
		info->edit_menu = NULL;
	}
}
/**
 * hildon_program_set_common_menu:
 * @self: The #HildonProgram in which the common menu should be used
 * @menu: A GtkMenu to use as common menu for the program
 *
 * Sets a GtkMenu that will appear in all the @HildonWindow registered
 * to the #HildonProgram. Only one common GtkMenu can be set, further
 * call will detach the previous common GtkMenu. A @HildonWindow
 * can use it's own GtkMenu with @hildon_window_set_menu
 **/
void
hildon_program_set_common_menu                  (HildonProgram *self, 
                                                 GtkMenu *menu)
{
    HildonProgramPrivate *priv;

    g_return_if_fail (HILDON_IS_PROGRAM (self));

    priv = HILDON_PROGRAM_GET_PRIVATE (self);
    g_assert (priv);

    if (priv->common_menu)
    {
        if (GTK_WIDGET_VISIBLE (priv->common_menu))
        {
            gtk_menu_popdown (GTK_MENU (priv->common_menu));
            gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->common_menu));
        }

        if (gtk_menu_get_attach_widget (GTK_MENU (priv->common_menu)))
        {
            gtk_menu_detach (GTK_MENU (priv->common_menu));
        }
        else
        {
            g_object_unref (priv->common_menu);
        }
    }

    priv->common_menu = GTK_WIDGET (menu);

    if (priv->common_menu)
    {
        g_object_ref (menu);
        gtk_object_sink (GTK_OBJECT (menu));
        gtk_widget_show_all (GTK_WIDGET (menu));
    }
}
/* Since we'll get hundred press events when thumbing the button, we'll need to
 * wait for a moment until reacting
 */
static gboolean
hn_others_button_press_collapser (HNOthersButton *button)
{
  g_return_val_if_fail (button, FALSE);
  
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button->priv->button)))
  {
    g_debug ("deactivating menu");
    gtk_menu_shell_deactivate (GTK_MENU_SHELL (TASKNAVIGATOR_ITEM (button)->menu));
    button->priv->collapse_id = 0;
    button->priv->thumb_pressed = FALSE;
    
    return FALSE;
  }

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->priv->button), TRUE);
  
  if (!TASKNAVIGATOR_ITEM (button)->menu)
    hn_others_button_create_menu (button);

  if (button->priv->thumb_pressed)
  {
    hildon_menu_set_thumb_mode (TASKNAVIGATOR_ITEM (button)->menu, TRUE);
  }
  else
  {
    hildon_menu_set_thumb_mode(TASKNAVIGATOR_ITEM (button)->menu, FALSE);
  }

  hn_others_button_menu_show (button);
  
  button->priv->collapse_id = 0;
  button->priv->thumb_pressed = FALSE;

  return FALSE;
}
static VALUE
rg_deactivate(VALUE self)
{
    gtk_menu_shell_deactivate(_SELF(self));
    return self;
}