Exemplo n.º 1
0
static GtkWidget *
panel_applet_get_edit_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GtkWidget   *menuitem;
	GtkWidget   *image;
	gboolean     movable;
	gboolean     removable;

	if (info->edit_menu)
		return info->edit_menu;

	if (panel_lockdown_get_panels_locked_down_s ())
		return NULL;

	menu = panel_applet_create_bare_menu (info);

	movable = panel_applet_can_freely_move (info);
	removable = panel_layout_is_writable ();

	menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (move_applet_callback), info);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_set_sensitive (menuitem, movable);

	menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel"));
	image = gtk_image_new_from_stock (GTK_STOCK_REMOVE,
					  GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
				       image);
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (applet_remove_callback), info);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_set_sensitive (menuitem, removable);

	info->edit_menu = menu;

	panel_lockdown_on_notify (panel_lockdown_get (),
				  "panels-locked-down",
				  G_OBJECT (info->edit_menu),
				  panel_applet_edit_menu_lockdown_changed,
				  info);

	return info->edit_menu;
}
Exemplo n.º 2
0
static GtkWidget *
panel_applet_get_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GList       *l;
	gboolean     added_anything = FALSE;

	if (info->menu)
		return info->menu;

	menu = panel_applet_create_bare_menu (info);

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

		if (user_menu->is_enabled_func && !user_menu->is_enabled_func ())
			continue;

		add_to_submenus (info, "", user_menu->name, user_menu, 
				 menu, info->user_menu);

		added_anything = TRUE;
	}

	if ( ! added_anything) {
                g_signal_handlers_disconnect_by_func (menu,
						      G_CALLBACK (applet_menu_show), info);
                g_signal_handlers_disconnect_by_func (menu,
						      G_CALLBACK (applet_menu_deactivate), info);

		g_object_unref (menu);
		return NULL;
	}

	info->menu = menu;

	panel_lockdown_on_notify (panel_lockdown_get (),
				  NULL,
				  G_OBJECT (info->menu),
				  panel_applet_menu_lockdown_changed,
				  info);

	return info->menu;
}
Exemplo n.º 3
0
static GtkWidget *
panel_menu_get (PanelWidget *panel, PanelData *pd)
{
	if (!pd->menu) {
		pd->menu = panel_context_menu_create (panel);
		if (pd->menu != NULL) {
			g_object_ref_sink (pd->menu);
			g_signal_connect (pd->menu, "deactivate",
					  G_CALLBACK (context_menu_deactivate),
					  pd);
			g_signal_connect (pd->menu, "show",
					  G_CALLBACK (context_menu_show), pd);

			panel_lockdown_on_notify (panel_lockdown_get (),
						  NULL,
						  G_OBJECT (pd->menu),
						  panel_menu_lockdown_changed,
						  pd);
		}
	}

	return pd->menu;
}
Exemplo n.º 4
0
static void
panel_action_button_load_helper (PanelWidget           *panel,
				 const char            *id,
				 GSettings             *settings,
				 PanelActionButtonType  type)
{
	PanelActionButton *button;

	g_return_if_fail (panel != NULL);

	button = g_object_new (PANEL_TYPE_ACTION_BUTTON, "action-type", type, NULL);

	button->priv->info = panel_applet_register (GTK_WIDGET (button), panel,
						    PANEL_OBJECT_ACTION, id,
						    settings,
						    NULL, NULL);
	if (!button->priv->info) {
		gtk_widget_destroy (GTK_WIDGET (button));
		return;
	}

	panel_widget_set_applet_expandable (panel, GTK_WIDGET (button), FALSE, TRUE);
	panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (button), TRUE);

	if (actions [button->priv->type].setup_menu)
		actions [button->priv->type].setup_menu (button);

	panel_lockdown_on_notify (panel_lockdown_get (),
				  NULL,
				  G_OBJECT (button),
				  panel_action_button_update_sensitivity,
				  button);

	g_signal_connect (button, "style-updated",
			  G_CALLBACK (panel_action_button_style_updated), NULL);
}
Exemplo n.º 5
0
static GtkWidget *
panel_applet_get_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GList       *l;
	gboolean     added_anything = FALSE;


	/**
	 *  Separator to split the menu
	 *
	 * APPLET ITEMS
	 * -------------
	 * Move
	 * Remove From Panel
	 */
	GtkSeparatorMenuItem	*separator;

	/**
	 * Variables for the edit menu
	 */

	GtkWidget   *menuitem;
	GtkWidget   *image;
	gboolean     movable;
	gboolean     removable;

	if (info->menu)
		return info->menu;

	menu = panel_applet_create_bare_menu (info);

	/**
	 * Moved the panel_applet_get_edit_menu code to here
	 * to recombine the menu as seen in the traditional
	 * Gnome 2 setup
	 */
	movable = panel_applet_can_freely_move (info);
	removable = panel_layout_is_writable ();

	// Hack. We always added something now :P
	added_anything = TRUE;

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

		if (user_menu->is_enabled_func && !user_menu->is_enabled_func ())
			continue;

		add_to_submenus (info, "", user_menu->name, user_menu, 
				 menu, info->user_menu);

		added_anything = TRUE;
	}

	// Add the separator before we add the move/remove items (less confusion)
	separator =  gtk_separator_menu_item_new ();
	gtk_widget_show (separator);
	gtk_menu_shell_append (GTK_MENU_SHELL(menu), separator);

	menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (move_applet_callback), info);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_set_sensitive (menuitem, movable);

	// TODO: Add a seperator

	menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel"));
	image = gtk_image_new_from_stock (GTK_STOCK_REMOVE,
					  GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
				       image);
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (applet_remove_callback), info);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_set_sensitive (menuitem, removable);

	if ( ! added_anything) {
                g_signal_handlers_disconnect_by_func (menu,
						      G_CALLBACK (applet_menu_show), info);
                g_signal_handlers_disconnect_by_func (menu,
						      G_CALLBACK (applet_menu_deactivate), info);

		g_object_unref (menu);
		return NULL;
	}

	info->menu = menu;

	panel_lockdown_on_notify (panel_lockdown_get (),
				  NULL,
				  G_OBJECT (info->menu),
				  panel_applet_menu_lockdown_changed,
				  info);

	return info->menu;
}
Exemplo n.º 6
0
void
panel_menu_items_append_lock_logout (GtkWidget *menu)
{
	GList      *children;
	GList      *last;
	GtkWidget  *item;

	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);
	if (last != NULL &&
	    GTK_IS_SEPARATOR (last->data))
		item = GTK_WIDGET (last->data);
	else
		item = add_menu_separator (menu);
	g_list_free (children);

	panel_lockdown_on_notify (panel_lockdown_get (),
				  NULL,
				  G_OBJECT (item),
				  panel_menu_items_lock_logout_separator_notified,
				  item);
	panel_menu_items_lock_logout_separator_notified (panel_lockdown_get (),
							 item);

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOCK,
							 NULL, NULL, TRUE);
	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-lock-screen",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	item = panel_menu_items_create_switch_user (FALSE);

	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-switch-user",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
							 NULL, NULL, TRUE);

	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-log-out",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	/* FIXME: should be dynamic */
	if (panel_session_manager_is_shutdown_available (panel_session_manager_get ())) {
		item = panel_menu_items_create_action_item_full (PANEL_ACTION_SHUTDOWN,
								 NULL, NULL, TRUE);
		if (item != NULL) {
			GtkWidget *sep;

			sep = add_menu_separator (menu);

			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

			g_object_bind_property (panel_lockdown_get (),
						"disable-log-out",
						sep,
						"visible",
						G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
			g_object_bind_property (panel_lockdown_get (),
						"disable-log-out",
						item,
						"visible",
						G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
		}
	}
}