In-process panel applets [was: Re: Memory statistics]



On Wed, 2006-04-26 at 23:40 -0400, Behdad Esfahbod wrote:

> Still, in-proc applets should save a lot more.  I have eight
> applet procs running, each taking 1mb of private-dirty.
> Federico, can you point us to where that technology is hiding?

Here are the patches we are using in SLED10.

They are mostly about switching from out-of-proc factories to in-proc
ones.  Also, applets which don't live in the gnome-panel package need
code changes to use the right gettext domain.

I *think* this covers all applets, but I'm not 100% sure.  Also, it
doesn't cover the various notification area icons - resapplet,
nm-applet, etc., because they are random programs and not really panel
applets.

Note that these patches are for GNOME 2.12, since that's what we use in
SLED10.  They may need some tweaking for 2.14.

It would be great to get some hard numbers on how much memory we save
with this :)  Any takers?

  Federico
Index: applets/clock/GNOME_ClockApplet_Factory.server.in.in
================================================================================
--- applets/clock/GNOME_ClockApplet_Factory.server.in.in
+++ applets/clock/GNOME_ClockApplet_Factory.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_ClockApplet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/clock-applet">
+	    type="shlib"
+	    location="@LIBDIR@/libclock-applet.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- applets/clock/Makefile.am
+++ applets/clock/Makefile.am
@@ -20,16 +20,16 @@
 	calendar-debug.h
 endif
 
-clock_applet_SOURCES = clock.c $(CALENDAR_SOURCES)
+libclock_applet_la_SOURCES = clock.c $(CALENDAR_SOURCES)
 
-clock_applet_LDADD =					\
+libclock_applet_la_LIBADD=					\
 	../../libpanel-applet/libpanel-applet-2.la	\
 	$(CLOCK_LIBS)
 
-libexec_PROGRAMS = clock-applet
+lib_LTLIBRARIES = libclock-applet.la
 
 GNOME_ClockApplet_Factory.server.in: GNOME_ClockApplet_Factory.server.in.in
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 uidir 	= $(datadir)/gnome-2.0/ui
 ui_DATA	= GNOME_ClockApplet.xml	
--- applets/clock/clock.c
+++ applets/clock/clock.c
@@ -2309,7 +2309,6 @@
 	gtk_container_set_border_width (GTK_CONTAINER (cd->toggle), 0);
 	gtk_container_add (GTK_CONTAINER (cd->applet), cd->toggle);
 
-	gtk_window_set_default_icon_name ("clock");
 	gtk_widget_show (cd->applet);
 
 	/* FIXME: Update this comment. */
@@ -2791,9 +2790,8 @@
 	return retval;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_ClockApplet_Factory",
+PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_ClockApplet_Factory",
                              PANEL_TYPE_APPLET,
                              "ClockApplet",
-                             "0",
                              clock_factory,
                              NULL);
--- applets/fish/GNOME_FishApplet_Factory.server.in.in
+++ applets/fish/GNOME_FishApplet_Factory.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_FishApplet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/fish-applet-2">
+	    type="shlib"
+	    location="@LIBDIR@/libfish-applet-2.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- applets/fish/Makefile.am
+++ applets/fish/Makefile.am
@@ -9,11 +9,11 @@
 	$(DISABLE_DEPRECATED_CFLAGS)				\
 	$(FISH_CFLAGS)
 
-libexec_PROGRAMS = fish-applet-2
+lib_LTLIBRARIES = libfish-applet-2.la
 
-fish_applet_2_SOURCES = fish.c
+libfish_applet_2_la_SOURCES = fish.c
 
-fish_applet_2_LDADD =					\
+libfish_applet_2_la_LIBADD =				\
 	../../libpanel-applet/libpanel-applet-2.la	\
 	$(FISH_LIBS)
 
@@ -48,7 +48,7 @@
 server_DATA     = $(server_in_files:.server.in=.server)
 
 $(server_in_files): $(server_in_files).in
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 CLEANFILES = $(server_DATA) $(server_DATA).in $(schemas_DATA)
 
--- applets/fish/fish.c
+++ applets/fish/fish.c
@@ -1842,7 +1842,6 @@
 					      NULL);
 	}
 
-	gtk_window_set_default_icon_name ("gnome-fish");
 	setup_fish_widget (fish);
 
 	return TRUE;
@@ -2026,9 +2025,8 @@
 	return type;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FishApplet_Factory",
+PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_FishApplet_Factory",
 			     fish_applet_get_type (),
 			     "That-stupid-fish",
-			     "0",
 			     fishy_factory,
 			     NULL)
--- applets/notification_area/GNOME_NotificationAreaApplet.server.in.in
+++ applets/notification_area/GNOME_NotificationAreaApplet.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_NotificationAreaApplet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/notification-area-applet">
+	    type="shlib"
+	    location="@LIBDIR@/libnotification-area-applet.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- applets/notification_area/Makefile.am
+++ applets/notification_area/Makefile.am
@@ -14,13 +14,13 @@
 	-DDATADIR=\"$(datadir)\"				\
 	-DLIBDIR=\"$(libdir)\"
 
-libexec_PROGRAMS = notification-area-applet
+lib_LTLIBRARIES = libnotification-area-applet.la
 
 EGGFILES=			\
 	eggtraymanager.h	\
 	eggtraymanager.c
 
-notification_area_applet_SOURCES =		\
+libnotification_area_applet_la_SOURCES =		\
 	fixedtip.h				\
 	fixedtip.c				\
 	main.c					\
@@ -30,7 +30,7 @@
 	eggmarshalers.h				\
 	eggmarshalers.c
 
-notification_area_applet_LDADD =			\
+libnotification_area_applet_la_LIBADD =			\
 	../../libpanel-applet/libpanel-applet-2.la	\
 	$(X_LIBS)					\
 	$(PANEL_LIBS)
@@ -40,7 +40,7 @@
 server_DATA     = GNOME_NotificationAreaApplet.server
 
 GNOME_NotificationAreaApplet.server.in: $(srcdir)/GNOME_NotificationAreaApplet.server.in.in
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 @INTLTOOL_SERVER_RULE@
 
--- applets/notification_area/main.c
+++ applets/notification_area/main.c
@@ -384,7 +384,6 @@
   
   gtk_container_add (GTK_CONTAINER (tray->applet), tray->frame);
   
-  gtk_window_set_default_icon_name ("panel-notification-area");
   gtk_widget_show_all (GTK_WIDGET (tray->applet));
   
   panel_applet_setup_menu_from_file (PANEL_APPLET (applet), 
@@ -397,18 +396,8 @@
   return TRUE;
 }
 
-#if 1
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory",
-			     PANEL_TYPE_APPLET,
-                             "NotificationArea",
-                             "0",
-                             applet_factory,
-                             NULL)
-
-#else
 
 PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory",
 				   PANEL_TYPE_APPLET,
 				   "NotificationArea",
 				    applet_factory, NULL);
-#endif
--- applets/wncklet/GNOME_Wncklet_Factory.server.in.in
+++ applets/wncklet/GNOME_Wncklet_Factory.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_Wncklet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/wnck-applet">
+	    type="shlib"
+	    location="@LIBDIR@/libwnck-applet.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- applets/wncklet/Makefile.am
+++ applets/wncklet/Makefile.am
@@ -1,4 +1,4 @@
-libexec_PROGRAMS = wnck-applet
+lib_LTLIBRARIES = libwnck-applet.la
 
 INCLUDES = \
 	-I$(top_builddir) \
@@ -16,7 +16,7 @@
         -DDATADIR=\"$(datadir)\" \
         -DLIBDIR=\"$(libdir)\"
 
-wnck_applet_SOURCES = \
+libwnck_applet_la_SOURCES = \
 	wncklet.c \
 	wncklet.h \
 	window-menu.c \
@@ -28,9 +28,9 @@
 	showdesktop.c \
 	showdesktop.h
 
-$(wnck_applet_OBJECTS): $(BUILT_SOURCES)
+$(libwnck_applet_la_OBJECTS): $(BUILT_SOURCES)
 
-wnck_applet_LDADD = \
+libwnck_applet_la_LIBADD = \
 	../../libpanel-applet/libpanel-applet-2.la \
 	$(WNCKLET_LIBS)
 
@@ -45,7 +45,7 @@
 server_DATA     = $(server_in_files:.server.in=.server)
 
 $(server_in_files): $(server_in_files).in
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 @INTLTOOL_SERVER_RULE@
 
--- applets/wncklet/wncklet.c
+++ applets/wncklet/wncklet.c
@@ -222,9 +222,8 @@
 }
 
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Wncklet_Factory",
+PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_Wncklet_Factory",
                              PANEL_TYPE_APPLET,
                              "WindowNavigationApplets",
-                             "0",
                              wncklet_factory,
                              NULL);
--- mixer/GNOME_MixerApplet.server.in.in
+++ mixer/GNOME_MixerApplet.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_MixerApplet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/mixer_applet2">
+	    type="shlib"
+	    location="@LIBDIR@/libmixer_applet2.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- mixer/Makefile.am
+++ mixer/Makefile.am
@@ -8,9 +8,9 @@
 	$(GNOME_APPLETS_CFLAGS)		\
 	$(GNOMEDESKTOP_CFLAGS)
 
-libexec_PROGRAMS = mixer_applet2
+lib_LTLIBRARIES = libmixer_applet2.la
 
-mixer_applet2_SOURCES = \
+libmixer_applet2_la_SOURCES = \
 	applet.c \
 	dock.c \
 	load.c \
@@ -22,7 +22,7 @@
 	keys.h \
 	preferences.h
 
-mixer_applet2_LDADD = 					\
+libmixer_applet2_la_LIBADD = 					\
 	$(MIXER_LIBS) 					\
 	$(GNOME_APPLETS_LIBS)				\
 	$(GNOMEDESKTOP_LIBS)
@@ -32,7 +32,7 @@
 server_DATA     = $(server_in_files:.server.in=.server)
 
 $(server_in_files): $(server_in_files:.server.in=.server.in.in)
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 @INTLTOOL_SERVER_RULE@
 
--- mixer/applet.c
+++ mixer/applet.c
@@ -47,6 +47,8 @@
 #include "keys.h"
 #include "preferences.h"
 
+#include <glib/gi18n-lib.h>
+
 #define IS_PANEL_HORIZONTAL(o) \
   (o == PANEL_APPLET_ORIENT_UP || o == PANEL_APPLET_ORIENT_DOWN)
 
@@ -210,7 +212,6 @@
   applet->image = GTK_IMAGE (image);
   gtk_container_add (GTK_CONTAINER (applet), image);
   gtk_widget_show (image);
-  gtk_window_set_default_icon_name ("volume-knob");
 
   /* dock window (expanded UI) */
   applet->pop = FALSE;
@@ -377,6 +378,7 @@
   gchar *key;
   gchar *active_element_name;
   gchar *active_track_name;
+  char *oldtextdomain;
   GstMixerTrack *first_track;
   gboolean res;
 
@@ -414,10 +416,14 @@
   }
 
   /* menu - done here because bonobo is intialized now */
+  oldtextdomain = strdup (textdomain (NULL));
+  textdomain (GETTEXT_PACKAGE);
   panel_applet_setup_menu_from_file (PANEL_APPLET (applet), 
 				     DATADIR,
 				     "GNOME_MixerApplet.xml",
 				     NULL, verbs, applet);
+  textdomain (oldtextdomain);
+  free (oldtextdomain);
   component = panel_applet_get_popup_component (PANEL_APPLET (applet));
   g_signal_connect (component, "ui-event", G_CALLBACK (cb_ui_event), applet);
 
--- mixer/dock.c
+++ mixer/dock.c
@@ -36,6 +36,8 @@
 
 #include "dock.h"
 
+#include <glib/gi18n-lib.h>
+
 static void	gnome_volume_applet_dock_class_init	(GnomeVolumeAppletDockClass *klass);
 static void	gnome_volume_applet_dock_init		(GnomeVolumeAppletDock *applet);
 static void	gnome_volume_applet_dock_dispose	(GObject *object);
--- mixer/load.c
+++ mixer/load.c
@@ -30,6 +30,8 @@
 
 #include "applet.h"
 
+#include <glib/gi18n-lib.h>
+
 static gint
 sort_by_rank (GstElement * a, GstElement * b)
 {
@@ -172,11 +174,10 @@
   return TRUE;
 }
 
-PANEL_APPLET_BONOBO_FACTORY (
+PANEL_APPLET_BONOBO_SHLIB_FACTORY (
   "OAFIID:GNOME_MixerApplet_Factory",
   GNOME_TYPE_VOLUME_APPLET,
   "mixer_applet2",
-  "0",
   gnome_volume_applet_factory,
   NULL
 )
--- mixer/preferences.c
+++ mixer/preferences.c
@@ -47,6 +47,8 @@
 #include "preferences.h"
 #include "keys.h"
 
+#include <glib/gi18n-lib.h>
+
 enum {
   COL_LABEL,
   COL_TRACK,
--- multiload/GNOME_MultiLoadApplet_Factory.server.in.in
+++ multiload/GNOME_MultiLoadApplet_Factory.server.in.in
@@ -1,8 +1,8 @@
 <oaf_info>
 
 <oaf_server iid="OAFIID:GNOME_MultiLoadApplet_Factory"
-	    type="exe"
-	    location="@LIBEXECDIR@/multiload-applet-2">
+	    type="shlib"
+	    location="@LIBDIR@/libmultiload-applet-2.so">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:Bonobo/GenericFactory:1.0"/>
--- multiload/Makefile.am
+++ multiload/Makefile.am
@@ -1,3 +1,4 @@
+
 SUBDIRS = docs
 
 INCLUDES =			\
@@ -7,9 +8,9 @@
 	$(GNOMEDESKTOP_CFLAGS) \
 	$(GNOME_LIBS2_CFLAGS)
 
-libexec_PROGRAMS = multiload-applet-2
+lib_LTLIBRARIES = libmultiload-applet-2.la
 
-multiload_applet_2_SOURCES = \
+libmultiload_applet_2_la_SOURCES = \
 			global.h	\
 			linux-proc.h	\
 			load-graph.h	\
@@ -20,7 +21,7 @@
 			autoscaler.c	\
 			autoscaler.h
 
-multiload_applet_2_LDADD = \
+libmultiload_applet_2_la_LIBADD = \
 				$(GNOME_APPLETS_LIBS) 	\
 				$(GTOP_APPLETS_LIBS)	\
 				$(GNOMEDESKTOP_LIBS)    \
@@ -49,7 +50,7 @@
 server_DATA     = $(server_in_files:.server.in=.server)
 
 $(server_in_files): $(server_in_files:.server.in=.server.in.in)
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+	sed -e "s|\ LIBDIR\@|$(libdir)|" $< > $@
 
 CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA)
 
--- multiload/main.c
+++ multiload/main.c
@@ -30,6 +30,8 @@
 
 #include "global.h"
 
+#include <glib/gi18n-lib.h>
+
 static void
 about_cb (BonoboUIComponent *uic,
 	  MultiloadApplet   *ma,
@@ -366,7 +368,7 @@
 	} else {
 		const char *msg;
 
-		msg = ngettext("%s:\n"
+		msg = dngettext(GETTEXT_PACKAGE, "%s:\n"
 			       "%u%% in use",
 			       "%s:\n"
 			       "%u%% in use",
@@ -502,6 +504,7 @@
 	MultiloadApplet *ma;
 	GConfClient *client;
 	BonoboUIComponent *popup_component;
+	char *oldtextdomain;
 	
 	ma = g_new0(MultiloadApplet, 1);
 	
@@ -511,17 +514,19 @@
 	ma->prop_dialog = NULL;
         ma->last_clicked = 0;
 
-	gtk_window_set_default_icon_name ("gnome-monitor");
-	
 	panel_applet_add_preferences (applet, "/schemas/apps/multiload/prefs", NULL);
 	panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
 
+	oldtextdomain = strdup (textdomain (NULL));
+	textdomain (GETTEXT_PACKAGE);
 	panel_applet_setup_menu_from_file (applet,
 					   DATADIR,
 					   "GNOME_MultiloadApplet.xml",
 					   NULL,
 					   multiload_menu_verbs,
 					  ma);	
+	textdomain (oldtextdomain);
+	free (oldtextdomain);
 
 	popup_component = panel_applet_get_popup_component (applet);
 
@@ -577,9 +582,8 @@
 	return retval;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MultiLoadApplet_Factory",
+PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_MultiLoadApplet_Factory",
 				   PANEL_TYPE_APPLET,
 				   "multiload",
-				   "0",
 				   multiload_factory,
 				   NULL);
--- multiload/properties.c
+++ multiload/properties.c
@@ -31,6 +31,8 @@
 
 #include "global.h"
 
+#include <glib/gi18n-lib.h>
+
 #define PROP_CPU		0
 #define PROP_MEM		1
 #define PROP_NET		2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]