Wed Sep 29 18:18:24 2004 Jonathan Blandford <jrb@redhat.com>

* configure.in: Add a temporary --enable-notification-icon.  This
        will prolly go away.

        * info-daemon/Makefile.am:
        * info-daemon/NetworkManagerInfo.c:
        * info-daemon/NetworkManagerInfo.h: Use a notification icon.

        * panel-applet/Makefile.am:
        * panel-applet/NMWirelessApplet.c: Turn into a notification icon
        * panel-applet/NMWirelessApplet.h:


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@180 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Jonathan Blandford 2004-09-29 22:22:05 +00:00
parent 9db0ae211a
commit 78bb8a008f
10 changed files with 236 additions and 97 deletions

View file

@ -1,3 +1,16 @@
Wed Sep 29 18:18:24 2004 Jonathan Blandford <jrb@redhat.com>
* configure.in: Add a temporary --enable-notification-icon. This
will prolly go away.
* info-daemon/Makefile.am:
* info-daemon/NetworkManagerInfo.c:
* info-daemon/NetworkManagerInfo.h: Use a notification icon.
* panel-applet/Makefile.am:
* panel-applet/NMWirelessApplet.c: Turn into a notification icon
* panel-applet/NMWirelessApplet.h:
Tue Sep 28 16:35:20 2004 Jonathan Blandford <jrb@redhat.com>
* panel-applet/NMWirelessApplet.c: Fix deadlock. Add a separator

View file

@ -1,4 +1,4 @@
SUBDIRS = src dispatcher-daemon info-daemon panel-applet initscript test po
SUBDIRS = src dispatcher-daemon $(notification_icon_dir) info-daemon initscript test po
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in

View file

@ -8,6 +8,8 @@ AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
GETTEXT_PACKAGE=NetworkManager
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
@ -135,6 +137,46 @@ fi
AC_SUBST(DBUS_SYS_DIR)
AC_DEFINE_UNQUOTED(DBUS_SYSTEMD_DIR, "$DBUS_SYS_DIR", [Where system.d dir for DBUS is])
AC_ARG_ENABLE(notification-icon, [ --enable-notification-icon builds the wireless applet as a notification icon], enable_notification_icon=$enableval, enable_notification_icon=yes)
AM_CONDITIONAL(BUILD_NOTIFICATION_ICON, test x$enable_notification_icon = xyes)
if test x$enable_notification_icon == xyes ; then
AC_DEFINE_UNQUOTED(BUILD_NOTIFICATION_ICON, "$BUILD_NOTIFICATION_ICON", [Should we build the notification icon instead of the applet])
notification_icon_dir="panel-applet"
AC_SUBST(notification_icon_dir)
fi
#### find the actual value for $prefix that we'll end up with
## (I know this is broken and should be done in the Makefile, but
## that's a major pain and almost nobody actually seems to care)
REAL_PREFIX=
if test "x$prefix" = "xNONE"; then
REAL_PREFIX=$ac_default_prefix
else
REAL_PREFIX=$prefix
fi
## temporarily change prefix and exec_prefix
old_prefix=$prefix
prefix=$REAL_PREFIX
if test "x$exec_prefix" = xNONE ; then
REAL_EXEC_PREFIX=$REAL_PREFIX
else
REAL_EXEC_PREFIX=$exec_prefix
fi
old_exec_prefix=$exec_prefix
exec_prefix=$REAL_EXEC_PREFIX
BINDIR_TMP="$bindir"
EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
AC_SUBST(EXPANDED_BINDIR)
AC_DEFINE_UNQUOTED(EXPANDED_BINDIR, "$EXPANDED_BINDIR", [Where the executables are installed])
## put prefix and exec_prefix back
prefix=$old_prefix
exec_prefix=$old_exec_prefix
AC_OUTPUT([
Makefile
src/Makefile

View file

@ -2,20 +2,21 @@
INCLUDES = \
$(NM_CFLAGS) \
$(GTK_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(GLADE_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(GLADE_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
-Wall \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DG_DISABLE_DEPRECATED \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DG_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
-DGLADEDIR=\""$(datadir)/NetworkManagerInfo/glade"\" \
-DBINDIR=\"$(bindir)\" \
-DGLADEDIR=\""$(datadir)/NetworkManagerInfo/glade"\" \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DVERSION="\"$(VERSION)\"" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DVERSION="\"$(VERSION)\"" \
-DLIBDIR=\""$(libdir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DDATADIR=\"$(datadir)\"
bin_PROGRAMS = NetworkManagerInfo
@ -29,7 +30,12 @@ NetworkManagerInfo_SOURCES = NetworkManagerInfo.h \
NetworkManagerInfoNetworksDialog.c \
NetworkManagerInfoNetworksDialog.h
NetworkManagerInfo_LDADD = $(NM_LIBS) $(GLADE_LIBS) $(GCONF_LIBS) $(GTK_LIBS) $(GDK_PIXBUF_LIBS) $(LIBGNOMEUI_LIBS)
NetworkManagerInfo_LDADD = $(NM_LIBS) \
$(GLADE_LIBS) \
$(GCONF_LIBS) \
$(GTK_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(LIBGNOMEUI_LIBS)
gladedir = $(datadir)/NetworkManagerInfo/glade
glade_DATA = passphrase.glade keyring.png networks.glade

View file

@ -35,6 +35,9 @@
#include <gconf/gconf-client.h>
#include <libgnome/gnome-init.h>
#include <libgnomeui/gnome-ui-init.h>
#include <sys/types.h>
#include <signal.h>
#include "config.h"
#include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfo.h"
#include "NetworkManagerInfoPassphraseDialog.h"
@ -91,6 +94,7 @@ int main( int argc, char *argv[] )
NMIAppInfo *app_info = NULL;
GMainLoop *loop;
guint notify_id;
GError *error;
struct poptOption options[] =
{
@ -99,6 +103,8 @@ int main( int argc, char *argv[] )
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
};
gchar *notification_icon_cmd[] = {LIBEXECDIR"/NetworkManagerNotification"};
options[0].arg = &no_daemon;
program = gnome_program_init ("NetworkManagerInfo", VERSION,
@ -175,16 +181,38 @@ int main( int argc, char *argv[] )
if (err == -1)
exit (1);
gtk_init (&argc, &argv);
gnome_program_init ("NetworkManagerInfo", VERSION, LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_NONE);
app_info->notification_icon_pid = 0;
#ifdef BUILD_NOTIFICATION_ICON
/*spawn the panel notification icon*/
if (!g_spawn_async (NULL,
notification_icon_cmd,
NULL, 0, NULL, NULL,
&(app_info->notification_icon_pid),
&error))
{
g_warning ("Could not spawn NetworkManager's notification icon (%s)", error->message);
g_error_free (error);
}
#endif
if (nmi_passphrase_dialog_init (app_info) != 0)
exit (1);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
gtk_main ();
if (app_info->notification_icon_pid > 0)
kill (app_info->notification_icon_pid, SIGTERM);
gconf_client_notify_remove (app_info->gconf_client, notify_id);
g_object_unref (G_OBJECT (app_info->gconf_client));
/*g_object_unref (app_info->notification_icon);*/
g_free (app_info);
return 0;

View file

@ -42,6 +42,12 @@ struct NMIAppInfo
GtkListStore *networks_list_store;
GdkPixbuf *padlock_pixbuf;
/*
GtkWidget *notification_icon;
*/
GPid notification_icon_pid;
};
typedef struct NMIAppInfo NMIAppInfo;

View file

@ -586,7 +586,7 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
dbus_bus_acquire_service (dbus_connection, NMI_DBUS_SERVICE, 0, &dbus_error);
if (dbus_error_is_set (&dbus_error))
{
syslog (LOG_ERR, "nmi_dbus_service_init() could not acquire service %s. dbus_bus_acquire_service() says: '%s'", NMI_DBUS_SERVICE, dbus_error.message);
syslog (LOG_ERR, "nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message);
dbus_error_free (&dbus_error);
return (-1);
}

View file

@ -1,12 +1,16 @@
SUBDIRS=icons
NULL=
NOTIFICATION_ICON_SOURCE=@NOTIFICATION_ICON_SRC@
INCLUDES = \
$(NM_CFLAGS) \
$(GLADE_CFLAGS) \
$(DBUS_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(PANEL_APPLET_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DG_DISABLE_DEPRECATED \
@ -15,11 +19,11 @@ INCLUDES = \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
$(NULL)
libexec_PROGRAMS = NMWirelessApplet
noinst_LTLIBRARIES = libnm_notification_applet.la
NMWirelessApplet_SOURCES = \
NMWirelessApplet.c \
NMWirelessApplet.h \
libnm_notification_applet_la_SOURCES = \
NMWirelessApplet.c \
NMWirelessApplet.h \
NMWirelessAppletDbus.c \
NMWirelessAppletDbus.h \
menu-info.c \
@ -30,20 +34,25 @@ NMWirelessApplet_SOURCES = \
gtkcellrendererprogress.h \
$(NULL)
NMWirelessApplet_LDADD = \
libnm_notification_applet_la_SOURCES += \
eggtrayicon.c \
eggtrayicon.h
libnm_notification_applet_la_LIBADD = \
$(NM_LIBS) \
$(LIBGLADE_LIBS) \
$(GLADE_LIBS) \
$(DBUS_LIBS) \
$(DBUS_GLIB_LIBS) \
$(PANEL_APPLET_LIBS) \
$(PANEL_APPLET_LIBS) \
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(NULL)
serverdir = $(libdir)/bonobo/servers
server_in_files = NMWirelessApplet.server.in
server_DATA = NMWirelessApplet.server
libexec_PROGRAMS = NetworkManagerNotification
$(server_DATA): $(srcdir)/$(server_in_files)
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
NetworkManagerNotification_SOURCES = main.c
NetworkManagerNotification_LDADD = ./libnm_notification_applet.la
uidir = $(datadir)/gnome-2.0/ui
ui_DATA = NMWirelessApplet.xml
@ -73,7 +82,6 @@ pixmap_DATA = \
CLEANFILES = $(server_DATA) *.bak *.gladep
EXTRA_DIST = \
$(server_in_files) \
$(pixmap_DATA) \
$(ui_DATA) \
$(glade_DATA) \

View file

@ -36,13 +36,14 @@
#include <math.h>
#include <dirent.h>
#include "config.h"
#include <gnome.h>
#include <panel-applet.h>
#include <panel-applet-gconf.h>
#include <libgnomeui/libgnomeui.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include "config.h"
#include "NMWirelessApplet.h"
#include "NMWirelessAppletDbus.h"
#include "menu-info.h"
@ -67,38 +68,23 @@ static char * pixmap_names[] =
static char *glade_file;
static void nmwa_about_cb (BonoboUIComponent *uic, NMWirelessApplet *applet);
static void nmwa_about_cb (NMWirelessApplet *applet);
static GtkWidget * nmwa_populate_menu (NMWirelessApplet *applet);
static void nmwa_dispose_menu_items (NMWirelessApplet *applet);
static gboolean do_not_eat_button_press (GtkWidget *widget, GdkEventButton *event);
static GObject * nmwa_constructor (GType type, guint n_props, GObjectConstructParam *construct_props);
#ifndef BUILD_NOTIFICATION_ICON
static const BonoboUIVerb nmwa_context_menu_verbs [] =
{
BONOBO_UI_UNSAFE_VERB ("NMWirelessAbout", nmwa_about_cb),
BONOBO_UI_VERB_END
};
#endif
static GType nmwa_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo info =
{
sizeof (PanelAppletClass),
NULL, NULL, NULL, NULL, NULL,
sizeof (NMWirelessApplet),
0, NULL, NULL
};
type = g_type_register_static (PANEL_TYPE_APPLET, "NMWirelessApplet", &info, 0);
}
return (type);
}
G_DEFINE_TYPE(NMWirelessApplet, nmwa, EGG_TYPE_TRAY_ICON)
/*
* nmwa_redraw
@ -264,7 +250,7 @@ static void show_warning_dialog (gboolean error, gchar *mesg, ...)
* Display our about dialog
*
*/
static void nmwa_about_cb (BonoboUIComponent *uic, NMWirelessApplet *applet)
static void nmwa_about_cb (NMWirelessApplet *applet)
{
GdkPixbuf *pixbuf;
char *file;
@ -279,7 +265,7 @@ static void nmwa_about_cb (BonoboUIComponent *uic, NMWirelessApplet *applet)
if (applet->about_dialog != NULL)
{
gtk_window_set_screen (GTK_WINDOW (applet->about_dialog), gtk_widget_get_screen (GTK_WIDGET (&applet->base)));
gtk_window_set_screen (GTK_WINDOW (applet->about_dialog), gtk_widget_get_screen (GTK_WIDGET (&applet->parent)));
gtk_window_present (GTK_WINDOW (applet->about_dialog));
return;
}
@ -358,6 +344,7 @@ static void nmwa_get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_i
gdk_window_get_origin (GTK_WIDGET (applet)->window, &tempx, &tempy);
gdk_window_get_geometry (GTK_WIDGET (applet)->window, NULL, NULL, &width, &height, NULL);
#ifndef BUILD_NOTIFICATION_ICON
switch (panel_applet_get_orient (PANEL_APPLET (applet)))
{
case PANEL_APPLET_ORIENT_DOWN:
@ -373,6 +360,7 @@ static void nmwa_get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_i
tempx += width;
break;
}
#endif
screen_width = gdk_screen_width ();
screen_height = gdk_screen_height ();
*x = CLAMP (tempx, 0, MAX (0, screen_width - reqmenu.width));
@ -849,6 +837,7 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
gint panel_size;
GtkWidget *menu_bar;
#if 0
panel_size = panel_applet_get_size (PANEL_APPLET (applet));
switch (panel_applet_get_orient(PANEL_APPLET (applet)))
{
@ -861,6 +850,7 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
horizontal = TRUE;
break;
}
#endif
/* construct pixmap widget */
applet->pixmap = gtk_image_new ();
@ -883,7 +873,7 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
applet->menu = gtk_menu_new();
gtk_menu_item_set_submenu (GTK_MENU_ITEM(applet->toplevel_menu), applet->menu);
g_signal_connect (applet->menu, "button_press_event", G_CALLBACK (do_not_eat_button_press), NULL);
g_signal_connect (menu_bar, "button_press_event", G_CALLBACK (do_not_eat_button_press), NULL);
applet->image_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
applet->encryption_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@ -897,25 +887,25 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
applet->about_dialog = NULL;
}
static void change_size_cb(PanelApplet *pa, gint s, NMWirelessApplet *applet)
{
nmwa_setup_widgets (applet);
nmwa_redraw_timeout (applet);
}
static void change_orient_cb(PanelApplet *pa, gint s, NMWirelessApplet *applet)
{
nmwa_setup_widgets (applet);
nmwa_redraw_timeout (applet);
}
static gboolean do_not_eat_button_press (GtkWidget *widget, GdkEventButton *event)
{
/* Don't worry about this for now
We can use it if we need a contectual menu
if (event->button != 1)
g_signal_stop_emission_by_name (widget, "button_press_event");
if (event->button == 3) {
g_message ("3nd button pressed");
return (TRUE);
}
*/
return (FALSE);
}
#if 0
static void change_background_cb(PanelApplet *a, PanelAppletBackgroundType type,
GdkColor *color, GdkPixmap *pixmap, NMWirelessApplet *applet)
{
@ -943,19 +933,18 @@ static void change_background_cb(PanelApplet *a, PanelAppletBackgroundType type,
gtk_rc_style_unref (rc_style);
}
#endif
/*
* nmwa_new
* nmwa_get_instance
*
* Create the initial instance of our wireless applet
*
*/
static GtkWidget * nmwa_new (NMWirelessApplet *applet)
static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
{
GError *error = NULL;
panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
gtk_widget_hide(GTK_WIDGET(applet));
applet->gconf_client = gconf_client_get_default ();
@ -995,20 +984,12 @@ static GtkWidget * nmwa_new (NMWirelessApplet *applet)
g_signal_connect (applet,"destroy", G_CALLBACK (nmwa_destroy),NULL);
#ifndef BUILD_NOTIFICATION_ICON
panel_applet_setup_menu_from_file (PANEL_APPLET (applet), NULL, "NMWirelessApplet.xml", NULL,
nmwa_context_menu_verbs, applet);
#endif
if (panel_applet_get_locked_down (PANEL_APPLET (applet)))
{
BonoboUIComponent *popup_component;
popup_component = panel_applet_get_popup_component (PANEL_APPLET (applet));
bonobo_ui_component_set_prop (popup_component, "/commands/NMWirelessApplet", "hidden", "1", NULL);
}
g_signal_connect (G_OBJECT (applet), "change_size", G_CALLBACK (change_size_cb), applet);
g_signal_connect (G_OBJECT (applet), "change_orient", G_CALLBACK (change_orient_cb), applet);
g_signal_connect (G_OBJECT (applet), "change_background", G_CALLBACK (change_background_cb), applet);
/* Start redraw timeout */
nmwa_start_redraw_timeout (applet);
@ -1029,7 +1010,7 @@ static gboolean nmwa_fill (NMWirelessApplet *applet)
return (FALSE);
}
gtk_widget_show (nmwa_new (applet));
gtk_widget_show (nmwa_get_instance (applet));
return (TRUE);
}
@ -1074,10 +1055,45 @@ static gboolean nmwa_factory (NMWirelessApplet *applet, const gchar *iid, gpoint
return (retval);
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:NMWirelessApplet_Factory",
nmwa_get_type (),
"wireless",
"0",
(PanelAppletFactoryCallback) nmwa_factory,
NULL)
static void
nmwa_init (NMWirelessApplet *applet)
{
setup_stock ();
nmwa_fill (applet);
}
static GObjectClass *parent_class = NULL;
static void nmwa_class_init (NMWirelessAppletClass *klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (gobject_class));
gobject_class->constructor = nmwa_constructor;
}
static GObject *nmwa_constructor (GType type,
guint n_props,
GObjectConstructParam *construct_props)
{
GObject *obj;
NMWirelessApplet *applet;
NMWirelessAppletClass *klass;
klass = NM_WIRELESS_APPLET_CLASS (g_type_class_peek (type));
obj = parent_class->constructor (type,
n_props,
construct_props);
applet = NM_WIRELESS_APPLET (obj);
return obj;
}
NMWirelessApplet *nmwa_new ()
{
return g_object_new (NM_TYPE_WIRELESS_APPLET, "title", "NetworkManager", NULL);
}

View file

@ -21,14 +21,18 @@
#ifndef NM_WIRELESS_APPLET_H
#define NM_WIRELESS_APPLET_H
#include "config.h"
#include <gnome.h>
#include <panel-applet.h>
#include <panel-applet-gconf.h>
#include <gconf/gconf-client.h>
#include <glade/glade.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#ifndef BUILD_NOTIFICATION_ICON
#include <panel-applet.h>
#include <panel-applet-gconf.h>
#else
#include "eggtrayicon.h"
#endif
typedef enum
{
@ -90,13 +94,29 @@ typedef struct
} NetworkDevice;
#ifdef BUILD_NOTIFICATION_ICON
#define NM_TYPE_WIRELESS_APPLET (nmwa_get_type())
#define NM_WIRELESS_APPLET(object) (G_TYPE_CHECK_INSTANCE_CAST((object), NM_TYPE_WIRELESS_APPLET, NMWirelessApplet))
#define NM_WIRELESS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_WIRELESS_APPLET, NMWirelessAppletClass))
#define NM_IS_WIRELESS_APPLET(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), NM_TYPE_WIRELESS_APPLET))
#define NM_IS_WIRELESS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_WIRELESS_APPLET))
#define NM_WIRELESS_APPLET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), NM_TYPE_WIRELESS_APPLET, NMWirelessAppletClass))
typedef struct
{
EggTrayIconClass parent_class;
} NMWirelessAppletClass;
#endif
/*
* Applet instance data
*
*/
typedef struct
{
PanelApplet base;
EggTrayIcon parent;
DBusConnection *connection;
GConfClient *gconf_client;
@ -129,6 +149,6 @@ typedef struct
} NMWirelessApplet;
NetworkDevice *nmwa_get_device_for_nm_device (NMWirelessApplet *applet, const char *nm_dev);
NetworkDevice *nmwa_get_device_for_nm_device (NMWirelessApplet *applet, const char *nm_dev);
NMWirelessApplet *nmwa_new ();
#endif