[network-manager-netbook/MplPanelClient: 23/44] Use libmoblin-panel for embedding.
- From: Tambet Ingo <tambeti src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-netbook/MplPanelClient: 23/44] Use libmoblin-panel for embedding.
- Date: Tue, 10 Nov 2009 14:11:39 +0000 (UTC)
commit 0d5267557645b91906b7f20c9ba7f0c2aa2ec7b1
Author: Tambet Ingo <tambet gmail com>
Date: Wed Sep 9 09:53:51 2009 +0300
Use libmoblin-panel for embedding.
.gitignore | 1 +
Makefile.am | 9 ++-
configure.in | 2 +-
network-manager-netbook.css.in | 123 ++++++++++++++++++++++++++++
src/Makefile.am | 3 +-
src/main.c | 40 +++------
src/nmn-applet.c | 175 +++++++++++++++++++++++++++++-----------
src/nmn-applet.h | 9 +-
src/nmn-plug.c | 123 ----------------------------
src/nmn-plug.h | 48 -----------
src/nmn-status-icon.c | 95 ++++++++++-----------
src/nmn-status-icon.h | 19 +++--
src/utils.c | 16 ++--
src/utils.h | 2 +-
14 files changed, 342 insertions(+), 323 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 3e4e0e0..5b77f60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@ install-sh
libtool
ltmain.sh
missing
+network-manager-netbook.css
POTFILES
po/*.gmo
shave
diff --git a/Makefile.am b/Makefile.am
index 0cb9a74..84ca73a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,11 +3,18 @@ SUBDIRS = icons src po
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = network-manager-netbook.desktop
+themedir = $(pkgdatadir)/theme
+theme_DATA = network-manager-netbook.css
+
+%.css: %.css.in
+ $(QUIET_GEN)sed -e "s|\ pkgdatadir\@|$(pkgdatadir)|" $< > $@
+
EXTRA_DIST = \
$(autostart_DATA) \
+ $(theme_DATA) \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
-DISTCLEANFILES = intltool-extract intltool-merge intltool-update
+DISTCLEANFILES = intltool-extract intltool-merge intltool-update network-manager-netbook.css
diff --git a/configure.in b/configure.in
index 58e3d29..0904aa6 100644
--- a/configure.in
+++ b/configure.in
@@ -22,7 +22,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
IT_PROG_INTLTOOL([0.35.0])
AM_GLIB_GNU_GETTEXT
-PKG_CHECK_MODULES(NMN, dbus-glib-1 >= 0.75 gtk+-2.0 gconf-2.0 gnome-keyring-1 libnm-util libnm_glib mobile-broadband-provider-info)
+PKG_CHECK_MODULES(NMN, dbus-glib-1 >= 0.75 gtk+-2.0 gconf-2.0 gnome-keyring-1 libnm-util libnm_glib mobile-broadband-provider-info moblin-panel-gtk)
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
AC_SUBST(GLIB_GENMARSHAL)
diff --git a/network-manager-netbook.css.in b/network-manager-netbook.css.in
new file mode 100644
index 0000000..1b641b1
--- /dev/null
+++ b/network-manager-netbook.css.in
@@ -0,0 +1,123 @@
+MnbToolbarButton {
+ background-color: #fff0;
+}
+
+MnbToolbarButton:checked {
+ border-image: url("file://@pkgdatadir@/icons/toolbar-button-active.png") 0 stretch;
+}
+
+MnbToolbarButton:hover, MnbToolbarButton:active {
+ border-image: url("file://@pkgdatadir@/icons/toolbar-button-hover.png") 0 stretch;
+}
+
+MnbToolbarButton#no-network {
+ background-image: url("file://@pkgdatadir@/icons/nm-no-connection-normal.png");
+}
+
+MnbToolbarButton#no-network:hover, MnbToolbarButton#no-network:active, MnbToolbarButton#no-network:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-no-connection-active.png");
+}
+
+MnbToolbarButton#device-wired {
+ background-image: url("file://@pkgdatadir@/icons/nm-device-wired-normal.png");
+}
+
+MnbToolbarButton#device-wired:hover, MnbToolbarButton#device-wired:active, MnbToolbarButton#device-wired:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-device-wired-active.png");
+}
+
+MnbToolbarButton#signal-100 {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-100-normal.png");
+}
+
+MnbToolbarButton#signal-100:hover, MnbToolbarButton#signal-100:active, MnbToolbarButton#signal-100:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-100-active.png");
+}
+
+MnbToolbarButton#signal-75 {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-75-normal.png");
+}
+
+MnbToolbarButton#signal-75:hover, MnbToolbarButton#signal-75:active, MnbToolbarButton#signal-75:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-75-active.png");
+}
+
+MnbToolbarButton#signal-50 {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-50-normal.png");
+}
+
+MnbToolbarButton#signal-50:hover, MnbToolbarButton#signal-50:active, MnbToolbarButton#signal-50:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-50-active.png");
+}
+
+MnbToolbarButton#signal-25 {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-25-normal.png");
+}
+
+MnbToolbarButton#signal-25:hover, MnbToolbarButton#signal-25:active, MnbToolbarButton#signal-25:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-25-active.png");
+}
+
+MnbToolbarButton#signal-00 {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-00-normal.png");
+}
+
+MnbToolbarButton#signal-00:hover, MnbToolbarButton#signal-00:active, MnbToolbarButton#signal-00:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-signal-00-active.png");
+}
+
+MnbToolbarButton#device-wwan {
+ background-image: url("file://@pkgdatadir@/icons/nm-device-wwan-normal.png");
+}
+
+MnbToolbarButton#device-wwan:hover, MnbToolbarButton#device-wwan:active, MnbToolbarButton#device-wwan:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-device-wwan-active.png");
+}
+
+MnbToolbarButton#progress-01 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-01-normal.png");
+}
+
+MnbToolbarButton#progress-01:hover, MnbToolbarButton#progress-01:active, MnbToolbarButton#progress-01:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-01-active.png");
+}
+
+MnbToolbarButton#progress-02 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-02-normal.png");
+}
+
+MnbToolbarButton#progress-02:hover, MnbToolbarButton#progress-02:active, MnbToolbarButton#progress-02:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-02-active.png");
+}
+
+MnbToolbarButton#progress-03 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-03-normal.png");
+}
+
+MnbToolbarButton#progress-03:hover, MnbToolbarButton#progress-03:active, MnbToolbarButton#progress-03:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-03-active.png");
+}
+
+MnbToolbarButton#progress-04 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-04-normal.png");
+}
+
+MnbToolbarButton#progress-04:hover, MnbToolbarButton#progress-04:active, MnbToolbarButton#progress-04:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-04-active.png");
+}
+
+MnbToolbarButton#progress-05 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-05-normal.png");
+}
+
+MnbToolbarButton#progress-05:hover, MnbToolbarButton#progress-05:active, MnbToolbarButton#progress-05:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-05-active.png");
+}
+
+MnbToolbarButton#progress-06 {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-06-normal.png");
+}
+
+MnbToolbarButton#progress-06:hover, MnbToolbarButton#progress-06:active, MnbToolbarButton#progress-06:checked {
+ background-image: url("file://@pkgdatadir@/icons/nm-progress-working-06-active.png");
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index daa16be..8cf8d4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ network_manager_netbook_CPPFLAGS = \
-DUIDIR=\""$(uidir)"\" \
-DICON_PATH=\""$(pkgdatadir)/icons/"\" \
-DNMNLOCALEDIR=\"$(datadir)/locale\" \
+ -DTHEME_PATH=\""$(pkgdatadir)/theme/"\" \
$(NULL)
network_manager_netbook_LDADD = \
@@ -46,8 +47,6 @@ network_manager_netbook_SOURCES = \
nmn-new-connection.h \
nmn-nm-data.c \
nmn-nm-data.h \
- nmn-plug.c \
- nmn-plug.h \
nmn-serial-handler.c \
nmn-serial-handler.h \
nmn-serial-item.c \
diff --git a/src/main.c b/src/main.c
index eaef09c..b760f6e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,32 +23,17 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <moblin-panel/mpl-panel-common.h>
+#include <moblin-panel/mpl-panel-gtk.h>
#include "nmn-applet.h"
#include "nmn-icon-cache.h"
#include "utils.h"
-#include "moblin-netbook-system-tray.h"
-
-static void
-embedded_callback (GObject *plug,
- GParamSpec *pspec,
- gpointer user_data)
-{
- NmnApplet *applet = NMN_APPLET (user_data);
- GtkWidget *w = GTK_WIDGET (plug);
- gboolean embedded;
-
- g_object_get (plug, "embedded", &embedded, NULL);
- gtk_widget_modify_bg (w, GTK_STATE_NORMAL, >k_widget_get_style (w)->white);
- nmn_applet_set_visible (applet, embedded);
-}
-
int
main (int argc, char *argv[])
{
+ MplPanelClient *panel_client;
NmnApplet *applet;
- GtkStatusIcon *status_icon;
- GtkWidget *plug;
bindtextdomain (GETTEXT_PACKAGE, NMNLOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -61,16 +46,17 @@ main (int argc, char *argv[])
"Moblin-Netbook",
NULL);
- applet = nmn_applet_new ();
- plug = nmn_applet_get_plug (applet);
- utils_set_main_widget (plug);
- status_icon = nmn_applet_get_status_icon (applet);
- g_signal_connect (plug,
- "notify::embedded",
- (GCallback) embedded_callback,
- applet);
+ panel_client = mpl_panel_gtk_new (MPL_PANEL_NETWORK,
+ _("network"),
+ THEME_PATH "/network-manager-netbook.css",
+ "unknown",
+ TRUE);
+
+ applet = nmn_applet_new (panel_client);
+ mpl_panel_client_set_height_request (panel_client, 500);
+
+ utils_set_main_widget (G_OBJECT (panel_client));
- mnbk_system_tray_init (status_icon, GTK_PLUG (plug), "wifi");
gtk_main ();
g_object_unref (applet);
diff --git a/src/nmn-applet.c b/src/nmn-applet.c
index 002ed81..d87134a 100644
--- a/src/nmn-applet.c
+++ b/src/nmn-applet.c
@@ -18,24 +18,32 @@
*/
#include <dbus/dbus-glib-lowlevel.h>
+#include <moblin-panel/mpl-panel-gtk.h>
#include <nbtk-gtk-light-switch.h>
#include "nmn-applet.h"
#include "nmn-nm-data.h"
#include "nmn-status-icon.h"
-#include "nmn-plug.h"
#include "nmn-networks.h"
#include "nmn-new-connection.h"
G_DEFINE_TYPE (NmnApplet, nmn_applet, G_TYPE_OBJECT)
+enum {
+ PROP_0,
+ PROP_PANEL_CLIENT,
+
+ LAST_PROP
+};
+
#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NMN_TYPE_APPLET, NmnAppletPrivate))
typedef struct {
NmnNMData *nm_data;
- GtkStatusIcon *status_icon;
+ MplPanelClient *panel_client;
+ GtkContainer *main_window;
+ NmnStatusIcon *status_icon;
GtkBuilder *builder;
- GtkWidget *plug;
GtkWidget *pane;
GtkWidget *list;
GtkTable *switch_table;
@@ -54,25 +62,13 @@ typedef struct {
} NmnAppletPrivate;
NmnApplet *
-nmn_applet_new ()
+nmn_applet_new (MplPanelClient *panel_client)
{
- return NMN_APPLET (g_object_new (NMN_TYPE_APPLET, NULL));
-}
+ g_return_val_if_fail (MPL_IS_PANEL_CLIENT (panel_client), NULL);
-GtkStatusIcon *
-nmn_applet_get_status_icon (NmnApplet *applet)
-{
- g_return_val_if_fail (NMN_IS_APPLET (applet), NULL);
-
- return GET_PRIVATE (applet)->status_icon;
-}
-
-GtkWidget *
-nmn_applet_get_plug (NmnApplet *applet)
-{
- g_return_val_if_fail (NMN_IS_APPLET (applet), NULL);
-
- return GET_PRIVATE (applet)->plug;
+ return NMN_APPLET (g_object_new (NMN_TYPE_APPLET,
+ NMN_APPLET_PANEL_CLIENT, panel_client,
+ NULL));
}
/* enable/disable wifi button */
@@ -275,9 +271,10 @@ add_new_connection_show (GtkButton *button,
{
NmnAppletPrivate *priv = GET_PRIVATE (user_data);
+ gtk_widget_hide (priv->pane);
+ gtk_container_remove (priv->main_window, priv->pane);
+ gtk_container_add (priv->main_window, priv->new_dialog);
gtk_widget_show (priv->new_dialog);
- nmn_plug_push (NMN_PLUG (priv->plug), priv->new_dialog);
- priv->pop_counter++;
}
static void
@@ -286,8 +283,10 @@ add_new_connection_hide (GtkWidget *widget,
{
NmnAppletPrivate *priv = GET_PRIVATE (user_data);
- nmn_plug_pop (NMN_PLUG (priv->plug));
- priv->pop_counter--;
+ gtk_widget_hide (priv->new_dialog);
+ gtk_container_remove (priv->main_window, priv->new_dialog);
+ gtk_container_add (priv->main_window, priv->pane);
+ gtk_widget_show (priv->pane);
}
static void
@@ -304,27 +303,28 @@ add_new_connection_setup (NmnApplet *applet)
g_signal_connect (priv->add_new_connection, "clicked", G_CALLBACK (add_new_connection_show), applet);
}
-void
-nmn_applet_set_visible (NmnApplet *applet,
- gboolean visible)
+static void
+show_begin_cb (MplPanelClient *panel_client,
+ gpointer user_data)
{
- NmnAppletPrivate *priv = GET_PRIVATE (applet);
+ NmnAppletPrivate *priv = GET_PRIVATE (user_data);
- nmn_status_icon_set_active (NMN_STATUS_ICON (priv->status_icon), visible);
-
- if (visible) {
- if (!priv->network_list_populated) {
- nmn_networks_populate (NMN_NETWORKS (priv->list));
- priv->network_list_populated = TRUE;
- }
- } else {
- while (priv->pop_counter > 0) {
- nmn_plug_pop (NMN_PLUG (priv->plug));
- priv->pop_counter--;
- }
+ if (!priv->network_list_populated) {
+ nmn_networks_populate (NMN_NETWORKS (priv->list));
+ priv->network_list_populated = TRUE;
}
}
+static void
+hide_end_cb (MplPanelClient *panel_client,
+ gpointer user_data)
+{
+ NmnAppletPrivate *priv = GET_PRIVATE (user_data);
+
+ if (gtk_bin_get_child (GTK_BIN (priv->main_window)) == priv->new_dialog)
+ add_new_connection_hide (NULL, user_data);
+}
+
static DBusGConnection *
init_dbus (void)
{
@@ -397,12 +397,15 @@ nmn_applet_init (NmnApplet *applet)
NM_DBUS_PATH_SETTINGS,
G_OBJECT (nmn_nm_data_get_user_settings (priv->nm_data)));
- nmn_status_icon_set_client (NMN_STATUS_ICON (priv->status_icon), NM_CLIENT (priv->nm_data));
+ nmn_status_icon_set_nm_client (priv->status_icon, NM_CLIENT (priv->nm_data));
priv->builder = gtk_builder_new ();
gtk_builder_add_from_file (priv->builder, UIDIR "/network-manager-netbook.ui", NULL);
priv->pane = GTK_WIDGET (gtk_builder_get_object (priv->builder, "main_container"));
+ g_object_ref (priv->pane);
+ gtk_widget_unparent (priv->pane);
+
priv->list = nmn_networks_new (priv->nm_data);
container = GTK_WIDGET (gtk_builder_get_object (priv->builder, "networks_container"));
@@ -416,12 +419,73 @@ nmn_applet_init (NmnApplet *applet)
enable_3g_setup (applet);
enable_network_setup (applet);
add_new_connection_setup (applet);
+}
- priv->plug = nmn_plug_new ();
- g_object_ref (priv->pane);
- gtk_widget_unparent (priv->pane);
- nmn_plug_push (NMN_PLUG (priv->plug), priv->pane);
- g_object_unref (priv->pane);
+static GObject*
+constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ NmnAppletPrivate *priv;
+
+ object = G_OBJECT_CLASS (nmn_applet_parent_class)->constructor
+ (type, n_construct_params, construct_params);
+
+ if (!object)
+ return NULL;
+
+ priv = GET_PRIVATE (object);
+
+ if (!priv->panel_client) {
+ g_warning ("Missing constructor arguments");
+ g_object_unref (object);
+ return NULL;
+ }
+
+ priv->main_window = GTK_CONTAINER (mpl_panel_gtk_get_window (MPL_PANEL_GTK (priv->panel_client)));
+ gtk_container_add (priv->main_window, priv->pane);
+
+ g_signal_connect (priv->panel_client, "show-begin", G_CALLBACK (show_begin_cb), object);
+ g_signal_connect (priv->panel_client, "hide-end", G_CALLBACK (hide_end_cb), object);
+
+ gtk_widget_show (GTK_WIDGET (priv->main_window));
+
+ return object;
+}
+
+static void
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NmnAppletPrivate *priv = GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_PANEL_CLIENT:
+ /* Construct only */
+ priv->panel_client = g_value_dup_object (value);
+ nmn_status_icon_set_panel_client (priv->status_icon, priv->panel_client);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ NmnAppletPrivate *priv = GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_PANEL_CLIENT:
+ g_value_set_object (value, priv->panel_client);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
@@ -437,6 +501,9 @@ dispose (GObject *object)
if (priv->new_dialog)
gtk_widget_destroy (priv->new_dialog);
+ if (priv->pane)
+ g_object_unref (priv->pane);
+
if (priv->builder)
g_object_unref (priv->builder);
@@ -446,8 +513,8 @@ dispose (GObject *object)
if (priv->nm_data)
g_object_unref (priv->nm_data);
- if (priv->plug)
- g_object_unref (priv->plug);
+ if (priv->panel_client)
+ g_object_unref (priv->panel_client);
G_OBJECT_CLASS (nmn_applet_parent_class)->dispose (object);
}
@@ -459,5 +526,17 @@ nmn_applet_class_init (NmnAppletClass *class)
g_type_class_add_private (object_class, sizeof (NmnAppletPrivate));
+ object_class->constructor = constructor;
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
object_class->dispose = dispose;
+
+ /* properties */
+ g_object_class_install_property
+ (object_class, PROP_PANEL_CLIENT,
+ g_param_spec_object (NMN_APPLET_PANEL_CLIENT,
+ "MplPanelClient",
+ "Panel client",
+ MPL_TYPE_PANEL_CLIENT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
diff --git a/src/nmn-applet.h b/src/nmn-applet.h
index 2ba4d89..314ffa7 100644
--- a/src/nmn-applet.h
+++ b/src/nmn-applet.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#include <moblin-panel/mpl-panel-client.h>
G_BEGIN_DECLS
@@ -32,6 +33,8 @@ G_BEGIN_DECLS
#define NMN_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NMN_TYPE_APPLET))
#define NMN_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMN_TYPE_APPLET, NmnAppletClass))
+#define NMN_APPLET_PANEL_CLIENT "panel-client"
+
typedef struct {
GObject parent;
} NmnApplet;
@@ -42,11 +45,7 @@ typedef struct {
GType nmn_applet_get_type (void);
-NmnApplet *nmn_applet_new (void);
-GtkStatusIcon *nmn_applet_get_status_icon (NmnApplet *applet);
-GtkWidget *nmn_applet_get_plug (NmnApplet *applet);
-void nmn_applet_set_visible (NmnApplet *applet,
- gboolean visible);
+NmnApplet *nmn_applet_new (MplPanelClient *panel_client);
G_END_DECLS
diff --git a/src/nmn-status-icon.c b/src/nmn-status-icon.c
index 0101380..49640cd 100644
--- a/src/nmn-status-icon.c
+++ b/src/nmn-status-icon.c
@@ -30,7 +30,7 @@
#define ACTIVATION_STEPS 6
-G_DEFINE_TYPE (NmnStatusIcon, nmn_status_icon, GTK_TYPE_STATUS_ICON)
+G_DEFINE_TYPE (NmnStatusIcon, nmn_status_icon, G_TYPE_OBJECT)
#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NMN_TYPE_STATUS_ICON, NmnStatusIconPrivate))
@@ -40,54 +40,27 @@ typedef struct {
} NmnIconHandler;
typedef struct {
- NMClient *client;
+ NMClient *nm_client;
+ MplPanelClient *panel_client;
char *current_image;
- gboolean active;
GSList *ac_list;
NmnIconHandler *ac_icon_handler;
} NmnStatusIconPrivate;
-GtkStatusIcon *
+NmnStatusIcon *
nmn_status_icon_new (void)
{
- return GTK_STATUS_ICON (g_object_new (NMN_TYPE_STATUS_ICON, NULL));
+ return NMN_STATUS_ICON (g_object_new (NMN_TYPE_STATUS_ICON, NULL));
}
static void
update_icon (NmnStatusIcon *self, const char *image)
{
NmnStatusIconPrivate *priv = GET_PRIVATE (self);
- char *real_image;
- GdkPixbuf *pixbuf;
- real_image = g_strconcat (image, priv->active ? "-active" : "-normal", NULL);
- pixbuf = nmn_icon_cache_get (real_image);
- g_free (real_image);
-
- if (pixbuf) {
- if (priv->current_image == NULL || strcmp (priv->current_image, image)) {
- g_free (priv->current_image);
- priv->current_image = g_strdup (image);
- }
-
- gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (self), pixbuf);
- }
-}
-
-void
-nmn_status_icon_set_active (NmnStatusIcon *self,
- gboolean active)
-{
- NmnStatusIconPrivate *priv;
-
- g_return_if_fail (NMN_IS_STATUS_ICON (self));
-
- priv = GET_PRIVATE (self);
- if (priv->active != active) {
- priv->active = active;
- update_icon (self, priv->current_image);
- }
+ if (priv->panel_client)
+ mpl_panel_client_request_button_style (priv->panel_client, image);
}
static void
@@ -128,7 +101,7 @@ activation_animation (gpointer data)
if (++handler->step > ACTIVATION_STEPS)
handler->step = 1;
- image = g_strdup_printf ("nm-progress-working-%02d", handler->step);
+ image = g_strdup_printf ("progress-%02d", handler->step);
update_icon (handler->parent.icon, image);
g_free (image);
@@ -160,7 +133,7 @@ icon_handler_ethernet_new (NmnStatusIcon *icon)
handler = g_new0 (NmnIconHandler, 1);
handler->destroy = g_free;
- update_icon (icon, "nm-device-wired");
+ update_icon (icon, "device-wired");
return handler;
}
@@ -204,15 +177,15 @@ ap_strength_changed (NMAccessPoint *ap, GParamSpec *pspec, gpointer user_data)
strength = CLAMP (strength, 0, 100);
if (strength > 80)
- image = "nm-signal-100";
+ image = "signal-100";
else if (strength > 55)
- image = "nm-signal-75";
+ image = "signal-75";
else if (strength > 30)
- image = "nm-signal-50";
+ image = "signal-50";
else if (strength > 5)
- image = "nm-signal-25";
+ image = "signal-25";
else
- image = "nm-signal-00";
+ image = "signal-00";
update_icon (handler->icon, image);
}
@@ -275,7 +248,7 @@ icon_handler_3g_new (NmnStatusIcon *icon)
handler = g_new0 (NmnIconHandler, 1);
handler->destroy = g_free;
- update_icon (icon, "nm-device-wwan");
+ update_icon (icon, "device-wwan");
return handler;
}
@@ -347,7 +320,7 @@ update_best_ac (NmnStatusIcon *self)
priv->ac_icon_handler = icon_handler_create (self, best_ac);
if (!priv->ac_icon_handler)
- update_icon (self, "nm-no-connection");
+ update_icon (self, "no-connection");
}
static void
@@ -406,8 +379,8 @@ active_connections_changed (NMClient *client,
}
void
-nmn_status_icon_set_client (NmnStatusIcon *self,
- NMClient *client)
+nmn_status_icon_set_nm_client (NmnStatusIcon *self,
+ NMClient *client)
{
NmnStatusIconPrivate *priv;
@@ -415,21 +388,40 @@ nmn_status_icon_set_client (NmnStatusIcon *self,
g_return_if_fail (NM_IS_CLIENT (client));
priv = GET_PRIVATE (self);
- priv->client = g_object_ref (client);
+ priv->nm_client = g_object_ref (client);
- g_signal_connect (priv->client, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
+ g_signal_connect (priv->nm_client, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
G_CALLBACK (active_connections_changed),
self);
active_connections_changed (client, NULL, self);
}
+void
+nmn_status_icon_set_panel_client (NmnStatusIcon *self,
+ MplPanelClient *panel_client)
+{
+ NmnStatusIconPrivate *priv;
+
+ g_return_if_fail (NMN_IS_STATUS_ICON (self));
+ g_return_if_fail (MPL_IS_PANEL_CLIENT (panel_client));
+
+ priv = GET_PRIVATE (self);
+ if (priv->panel_client)
+ g_object_unref (priv->panel_client);
+
+ priv->panel_client = g_object_ref (panel_client);
+
+ /* FIXME: Nothing ever sets priv->current_image */
+ update_icon (self, priv->current_image);
+}
+
/*****************************************************************************/
static gboolean
set_initial_icon (gpointer data)
{
- update_icon (NMN_STATUS_ICON (data), "nm-no-connection");
+ update_icon (NMN_STATUS_ICON (data), "no-connection");
return FALSE;
}
@@ -450,8 +442,11 @@ finalize (GObject *object)
ac_list_destroy (NMN_STATUS_ICON (object));
- if (priv->client)
- g_object_unref (priv->client);
+ if (priv->panel_client)
+ g_object_unref (priv->panel_client);
+
+ if (priv->nm_client)
+ g_object_unref (priv->nm_client);
G_OBJECT_CLASS (nmn_status_icon_parent_class)->finalize (object);
}
diff --git a/src/nmn-status-icon.h b/src/nmn-status-icon.h
index 05a2acb..fc6e8f9 100644
--- a/src/nmn-status-icon.h
+++ b/src/nmn-status-icon.h
@@ -20,8 +20,9 @@
#ifndef NMN_STATUS_ICON_H
#define NMN_STATUS_ICON_H
-#include <gtk/gtk.h>
+#include <glib-object.h>
#include <nm-client.h>
+#include <moblin-panel/mpl-panel-client.h>
G_BEGIN_DECLS
@@ -33,22 +34,22 @@ G_BEGIN_DECLS
#define NMN_STATUS_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMN_TYPE_STATUS_ICON, NmnStatusIconClass))
typedef struct {
- GtkStatusIcon parent;
+ GObject parent;
} NmnStatusIcon;
typedef struct {
- GtkStatusIconClass parent;
+ GObjectClass parent;
} NmnStatusIconClass;
GType nmn_status_icon_get_type (void);
-GtkStatusIcon *nmn_status_icon_new (void);
-void nmn_status_icon_set_client (NmnStatusIcon *self,
- NMClient *client);
+NmnStatusIcon *nmn_status_icon_new (void);
+void nmn_status_icon_set_nm_client (NmnStatusIcon *self,
+ NMClient *nm_client);
-void nmn_status_icon_set_active (NmnStatusIcon *self,
- gboolean active);
+void nmn_status_icon_set_panel_client (NmnStatusIcon *self,
+ MplPanelClient *panel_client);
G_END_DECLS
-#endif /* NMN_STATUS_H */
+#endif /* NMN_STATUS_ICON_H */
diff --git a/src/utils.c b/src/utils.c
index 6b53492..0486678 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -24,12 +24,12 @@
#include <netinet/ether.h>
#include <glib.h>
+#include <moblin-panel/mpl-panel-client.h>
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-access-point.h>
-
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-wireless.h>
@@ -858,7 +858,7 @@ utils_ether_ntop (const struct ether_addr *mac)
mac->ether_addr_octet[4], mac->ether_addr_octet[5]);
}
-static GtkWidget *main_widget = NULL;
+static MplPanelClient *main_widget = NULL;
static void
main_widget_destroyed (gpointer data,
@@ -868,19 +868,19 @@ main_widget_destroyed (gpointer data,
}
void
-utils_set_main_widget (GtkWidget *widget)
+utils_set_main_widget (GObject *panel_client)
{
if (main_widget)
- g_object_weak_unref (G_OBJECT (widget), main_widget_destroyed, NULL);
+ g_object_weak_unref (G_OBJECT (main_widget), main_widget_destroyed, NULL);
- main_widget = widget;
- if (widget)
- g_object_weak_ref (G_OBJECT (widget), main_widget_destroyed, NULL);
+ main_widget = (MplPanelClient *) panel_client;
+ if (panel_client)
+ g_object_weak_ref (G_OBJECT (panel_client), main_widget_destroyed, NULL);
}
void
utils_hide_main_widget (void)
{
if (main_widget)
- gtk_widget_hide (main_widget);
+ mpl_panel_client_request_hide (main_widget);
}
diff --git a/src/utils.h b/src/utils.h
index 752022d..396b2b1 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -54,7 +54,7 @@ char *utils_ether_ntop (const struct ether_addr *mac);
gboolean utils_mac_valid (const struct ether_addr *addr);
/* Ugh, please avert your eyes... */
-void utils_set_main_widget (GtkWidget *widget);
+void utils_set_main_widget (GObject *panel_client);
void utils_hide_main_widget (void);
#endif /* UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]