[gnome-panel/wip/user-menu: 7/11] panel: Add user status menu
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/user-menu: 7/11] panel: Add user status menu
- Date: Thu, 31 Mar 2011 13:10:31 +0000 (UTC)
commit c5b7e7c7718e489caf315787e33a223994d3cfa8
Author: Vincent Untz <vuntz gnome org>
Date: Thu Mar 31 17:30:36 2011 +0530
panel: Add user status menu
This is a new object, based on PanelMenuBarObject.
This breaks the string freeze, with the name and description of the
object.
gnome-panel/Makefile.am | 2 +
gnome-panel/applet.c | 2 +
gnome-panel/panel-addto.c | 21 ++++++-
gnome-panel/panel-enums.h | 3 +-
gnome-panel/panel-object-loader.c | 9 +++-
gnome-panel/panel-user-menu.c | 120 +++++++++++++++++++++++++++++++++++++
gnome-panel/panel-user-menu.h | 68 +++++++++++++++++++++
gnome-panel/panel.c | 12 ++++
8 files changed, 234 insertions(+), 3 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 11485ff..814c4ac 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -68,6 +68,7 @@ panel_sources = \
panel-layout.c \
panel-modules.c \
panel-object-loader.c \
+ panel-user-menu.c \
panel-applet-info.c
panel_headers = \
@@ -119,6 +120,7 @@ panel_headers = \
panel-modules.h \
panel-object-loader.h \
panel-schemas.h \
+ panel-user-menu.h \
panel-applet-info.h
gnome_panel_SOURCES = \
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index f42a2ee..11d9e4e 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -69,6 +69,7 @@ panel_applet_set_dnd_enabled (AppletInfo *info,
break;
case PANEL_OBJECT_MENU_BAR:
case PANEL_OBJECT_SEPARATOR:
+ case PANEL_OBJECT_USER_MENU:
break;
default:
g_assert_not_reached ();
@@ -198,6 +199,7 @@ applet_callback_callback (GtkWidget *widget,
*/
break;
case PANEL_OBJECT_SEPARATOR:
+ case PANEL_OBJECT_USER_MENU:
break;
default:
g_assert_not_reached ();
diff --git a/gnome-panel/panel-addto.c b/gnome-panel/panel-addto.c
index 09f832c..3ab3590 100644
--- a/gnome-panel/panel-addto.c
+++ b/gnome-panel/panel-addto.c
@@ -47,6 +47,7 @@
#include "panel-util.h"
#include "panel-addto.h"
#include "panel-icon-names.h"
+#include "panel-user-menu.h"
typedef struct {
PanelWidget *panel_widget;
@@ -86,7 +87,8 @@ typedef enum {
PANEL_ADDTO_LAUNCHER_NEW,
PANEL_ADDTO_MENU,
PANEL_ADDTO_MENUBAR,
- PANEL_ADDTO_SEPARATOR
+ PANEL_ADDTO_SEPARATOR,
+ PANEL_ADDTO_USER_MENU
} PanelAddtoItemType;
typedef struct {
@@ -166,7 +168,19 @@ static PanelAddtoItemInfo internal_addto_items [] = {
NULL,
NULL,
"SEPARATOR:NEW",
+ TRUE },
+
+ { PANEL_ADDTO_USER_MENU,
+ N_("User Menu"),
+ N_("User status menu"),
+ PANEL_ICON_USER_AVAILABLE,
+ PANEL_ACTION_NONE,
+ NULL,
+ NULL,
+ NULL,
+ "USERMENU:NEW",
TRUE }
+
};
enum {
@@ -804,6 +818,11 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
dialog->insert_pack_type,
pack_index);
break;
+ case PANEL_ADDTO_USER_MENU:
+ panel_user_menu_create (dialog->panel_widget->toplevel,
+ dialog->insert_pack_type,
+ pack_index);
+ break;
}
}
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index 419d2c9..1c64d7e 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -56,7 +56,8 @@ typedef enum {
PANEL_OBJECT_APPLET,
PANEL_OBJECT_ACTION,
PANEL_OBJECT_MENU_BAR,
- PANEL_OBJECT_SEPARATOR
+ PANEL_OBJECT_SEPARATOR,
+ PANEL_OBJECT_USER_MENU
} PanelObjectType;
typedef enum {
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index ffd5048..4480c95 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -44,6 +44,7 @@
#include "panel-menu-bar.h"
#include "panel-menu-button.h"
#include "panel-separator.h"
+#include "panel-user-menu.h"
#include "panel-object-loader.h"
@@ -224,6 +225,11 @@ panel_object_loader_idle_handler (gpointer dummy)
object->id,
object->settings);
break;
+ case PANEL_OBJECT_USER_MENU:
+ panel_user_menu_load (panel_widget,
+ object->id,
+ object->settings);
+ break;
default:
g_assert_not_reached ();
break;
@@ -362,7 +368,8 @@ static struct {
{ PANEL_OBJECT_MENU_BAR, "MenuBar" , FALSE },
{ PANEL_OBJECT_MENU, "MenuButton" , FALSE },
{ PANEL_OBJECT_LAUNCHER, "Launcher" , FALSE },
- { PANEL_OBJECT_SEPARATOR, "Separator" , FALSE }
+ { PANEL_OBJECT_SEPARATOR, "Separator" , FALSE },
+ { PANEL_OBJECT_USER_MENU, "UserMenu" , FALSE }
};
char *
diff --git a/gnome-panel/panel-user-menu.c b/gnome-panel/panel-user-menu.c
new file mode 100644
index 0000000..2ff36f4
--- /dev/null
+++ b/gnome-panel/panel-user-menu.c
@@ -0,0 +1,120 @@
+/*
+ * panel-user-menu.c: user status menu
+ *
+ * Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2004 Vincent Untz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ * Vincent Untz <vincent vuntz net>
+ */
+
+#include <config.h>
+
+#include "applet.h"
+#include "panel-layout.h"
+#include "panel-menu-bar-object.h"
+#include "panel-menu-items.h"
+
+#include "panel-user-menu.h"
+
+G_DEFINE_TYPE (PanelUserMenu, panel_user_menu, PANEL_TYPE_MENU_BAR_OBJECT)
+
+#define PANEL_USER_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_USER_MENU, PanelUserMenuPrivate))
+
+struct _PanelUserMenuPrivate {
+ AppletInfo *info;
+ PanelWidget *panel;
+
+ GtkWidget *desktop_item;
+};
+
+static void
+panel_user_menu_init (PanelUserMenu *usermenu)
+{
+ usermenu->priv = PANEL_USER_MENU_GET_PRIVATE (usermenu);
+
+ usermenu->priv->info = NULL;
+
+ usermenu->priv->desktop_item = panel_desktop_menu_item_new (TRUE, TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (usermenu),
+ usermenu->priv->desktop_item);
+ gtk_widget_show (usermenu->priv->desktop_item);
+}
+
+static void
+panel_user_menu_parent_set (GtkWidget *widget,
+ GtkWidget *previous_parent)
+{
+ PanelUserMenu *usermenu = PANEL_USER_MENU (widget);
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+ g_assert (!parent || PANEL_IS_WIDGET (parent));
+
+ usermenu->priv->panel = (PanelWidget *) parent;
+
+ if (usermenu->priv->desktop_item)
+ panel_desktop_menu_item_set_panel (usermenu->priv->desktop_item,
+ usermenu->priv->panel);
+}
+
+static void
+panel_user_menu_class_init (PanelUserMenuClass *klass)
+{
+ GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+
+ widget_class->parent_set = panel_user_menu_parent_set;
+
+ g_type_class_add_private (klass, sizeof (PanelUserMenuPrivate));
+}
+
+void
+panel_user_menu_load (PanelWidget *panel,
+ const char *id,
+ GSettings *settings)
+{
+ PanelUserMenu *usermenu;
+
+ g_return_if_fail (panel != NULL);
+
+ usermenu = g_object_new (PANEL_TYPE_USER_MENU, NULL);
+
+ usermenu->priv->info = panel_applet_register (
+ GTK_WIDGET (usermenu), panel,
+ PANEL_OBJECT_USER_MENU, id,
+ settings,
+ NULL, NULL);
+ if (!usermenu->priv->info) {
+ gtk_widget_destroy (GTK_WIDGET (usermenu));
+ return;
+ }
+
+ panel_menu_bar_object_object_load_finish (PANEL_MENU_BAR_OBJECT (usermenu),
+ panel);
+}
+
+void
+panel_user_menu_create (PanelToplevel *toplevel,
+ PanelObjectPackType pack_type,
+ int pack_index)
+{
+ panel_layout_object_create (PANEL_OBJECT_USER_MENU, NULL,
+ panel_toplevel_get_id (toplevel),
+ pack_type, pack_index);
+}
diff --git a/gnome-panel/panel-user-menu.h b/gnome-panel/panel-user-menu.h
new file mode 100644
index 0000000..f275592
--- /dev/null
+++ b/gnome-panel/panel-user-menu.h
@@ -0,0 +1,68 @@
+/*
+ * panel-user-menu.h: user status menu
+ *
+ * Copyright (C) 2003 Sun Microsystems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_USER_MENU_H__
+#define __PANEL_USER_MENU_H__
+
+#include <gtk/gtk.h>
+
+#include "panel-menu-bar-object.h"
+#include "panel-widget.h"
+
+G_BEGIN_DECLS
+
+#define PANEL_TYPE_USER_MENU (panel_user_menu_get_type ())
+#define PANEL_USER_MENU(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_USER_MENU, PanelUserMenu))
+#define PANEL_USER_MENU_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_USER_MENU, PanelUserMenuClass))
+#define PANEL_IS_USER_MENU(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_USER_MENU))
+#define PANEL_IS_USER_MENU_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_USER_MENU))
+#define PANEL_USER_MENU_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_USER_MENU, PanelUserMenuClass))
+
+typedef struct _PanelUserMenu PanelUserMenu;
+typedef struct _PanelUserMenuClass PanelUserMenuClass;
+typedef struct _PanelUserMenuPrivate PanelUserMenuPrivate;
+
+struct _PanelUserMenu{
+ PanelMenuBarObject usermenu;
+
+ PanelUserMenuPrivate *priv;
+};
+
+struct _PanelUserMenuClass {
+ PanelMenuBarObjectClass usermenu_class;
+};
+
+GType panel_user_menu_get_type (void) G_GNUC_CONST;
+
+void panel_user_menu_create (PanelToplevel *toplevel,
+ PanelObjectPackType pack_type,
+ int pack_index);
+
+void panel_user_menu_load (PanelWidget *panel,
+ const char *id,
+ GSettings *settings);
+
+G_END_DECLS
+
+#endif /* __PANEL_USER_MENU_H__ */
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index f21f73f..8565197 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -42,6 +42,7 @@
#include "panel-icon-names.h"
#include "panel-layout.h"
#include "panel-schemas.h"
+#include "panel-user-menu.h"
enum {
TARGET_URL,
@@ -77,6 +78,7 @@ orientation_change (AppletInfo *info,
button_widget_set_orientation (BUTTON_WIDGET (info->widget), orientation);
break;
case PANEL_OBJECT_MENU_BAR:
+ case PANEL_OBJECT_USER_MENU:
panel_menu_bar_object_set_orientation (PANEL_MENU_BAR_OBJECT (info->widget), orientation);
break;
case PANEL_OBJECT_SEPARATOR:
@@ -145,6 +147,7 @@ back_change (AppletInfo *info,
PANEL_APPLET_FRAME (info->widget), panel->background.type);
break;
case PANEL_OBJECT_MENU_BAR:
+ case PANEL_OBJECT_USER_MENU:
panel_menu_bar_object_change_background (PANEL_MENU_BAR_OBJECT (info->widget));
break;
case PANEL_OBJECT_SEPARATOR:
@@ -956,6 +959,15 @@ drop_internal_applet (PanelWidget *panel,
success = FALSE;
}
+ } else if (!strcmp (applet_type, "USERMENU:NEW")) {
+ if (panel_layout_is_writable ()) {
+ panel_user_menu_create (panel->toplevel,
+ pack_type, pack_index);
+ success = TRUE;
+ } else {
+ success = FALSE;
+ }
+
} else if (!strcmp(applet_type,"LAUNCHER:ASK")) {
if (panel_layout_is_writable ()) {
ask_about_launcher (NULL, panel, pack_type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]