Index: Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/Makefile.am,v retrieving revision 1.79 diff -u -u -r1.79 Makefile.am --- Makefile.am 12 Dec 2005 18:34:48 -0000 1.79 +++ Makefile.am 30 Dec 2005 18:06:52 -0000 @@ -20,10 +20,10 @@ SUBDIRS = \ po \ - idl \ icons \ - gnome-panel \ libpanel-applet \ + gnome-panel \ + gnome-applets-manager \ applets \ help \ doc \ Index: configure.in =================================================================== RCS file: /cvs/gnome/gnome-panel/configure.in,v retrieving revision 1.637 diff -u -u -r1.637 configure.in --- configure.in 15 Dec 2005 08:35:41 -0000 1.637 +++ configure.in 30 Dec 2005 18:06:52 -0000 @@ -49,8 +49,6 @@ LIBGLADE_REQUIRED=2.5.0 LIBGNOME_REQUIRED=2.13.0 LIBGNOMEUI_REQUIRED=2.5.4 -LIBBONOBOUI_REQUIRED=2.1.1 -ORBIT_REQUIRED=2.4.0 GNOME_VFS_REQUIRED=2.9.1 LIBWNCK_REQUIRED=2.11.91 GCONF_REQUIRED=2.6.1 @@ -58,17 +56,22 @@ LIBECAL_REQUIRED=0.0.97 LIBEDATASERVERUI_REQUIRED=1.2.0 CAIRO_REQUIRED=1.0.0 +DBUS_GLIB=0.60 dnl pkg-config dependency checks -PKG_CHECK_MODULES(PANEL, ORBit-2.0 >= $ORBIT_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED) +PKG_CHECK_MODULES(PANEL, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED dbus-glib-1 >= $DBUS_GLIB) AC_SUBST(PANEL_CFLAGS) AC_SUBST(PANEL_LIBS) -PKG_CHECK_MODULES(LIBPANEL_APPLET, ORBit-2.0 >= $ORBIT_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED) +PKG_CHECK_MODULES(LIBPANEL_APPLET, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED dbus-glib-1 >= $DBUS_GLIB) AC_SUBST(LIBPANEL_APPLET_CFLAGS) AC_SUBST(LIBPANEL_APPLET_LIBS) +PKG_CHECK_MODULES(APPLETS_MANAGER, gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED dbus-glib-1 >= $DBUS_GLIB) +AC_SUBST(APPLETS_MANAGER_CFLAGS) +AC_SUBST(APPLETS_MANAGER_LIBS) + PKG_CHECK_MODULES(WNCKLET, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED) AC_SUBST(WNCKLET_CFLAGS) AC_SUBST(WNCKLET_LIBS) @@ -97,7 +100,7 @@ fi AM_CONDITIONAL(HAVE_LIBECAL, test -n "$LIBECAL_REQUIREMENT") -PKG_CHECK_MODULES(CLOCK, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $LIBECAL_REQUIREMENT) +PKG_CHECK_MODULES(CLOCK, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $LIBECAL_REQUIREMENT dbus-glib-1 >= $DBUS_GLIB) AC_SUBST(CLOCK_CFLAGS) AC_SUBST(CLOCK_LIBS) @@ -145,14 +148,10 @@ dnl IDL directories -ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`" -AC_SUBST(ORBIT_IDL) - -BONOBO_IDLDIR="`$PKG_CONFIG --variable=idldir libbonobo-2.0`" -AC_SUBST(BONOBO_IDLDIR) - -BONOBO_ACT_IDLDIR="`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`" -AC_SUBST(BONOBO_ACT_IDLDIR) +AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool], [no]) +if test x$DBUS_BINDING_TOOL = "xno" ; then + AC_MSG_ERROR([dbus-binding-tool executable not found in your path - should be installed with dbus glib bindings]) +fi dnl Language Support @@ -198,12 +197,12 @@ AC_OUTPUT([ Makefile -idl/Makefile icons/Makefile gnome-panel/Makefile libpanel-applet/libpanelapplet-2.0.pc libpanel-applet/libpanelapplet-2.0-uninstalled.pc libpanel-applet/Makefile +gnome-applets-manager/Makefile po/Makefile.in applets/Makefile applets/clock/Makefile Index: applets/clock/GNOME_ClockApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/clock/GNOME_ClockApplet.xml,v retrieving revision 1.9 diff -u -u -r1.9 GNOME_ClockApplet.xml --- applets/clock/GNOME_ClockApplet.xml 11 Jun 2004 10:53:16 -0000 1.9 +++ applets/clock/GNOME_ClockApplet.xml 30 Dec 2005 18:06:52 -0000 @@ -1,20 +1,11 @@ - - - - - + + + + - - - - - - - + + + + + + Index: applets/clock/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/clock/Makefile.am,v retrieving revision 1.71 diff -u -u -r1.71 Makefile.am --- applets/clock/Makefile.am 4 Nov 2004 17:11:10 -0000 1.71 +++ applets/clock/Makefile.am 30 Dec 2005 18:06:52 -0000 @@ -28,17 +28,17 @@ libexec_PROGRAMS = clock-applet -GNOME_ClockApplet_Factory.server.in: GNOME_ClockApplet_Factory.server.in.in +org.gnome.panel.applet.Clock.service.in: org.gnome.panel.applet.Clock.service.in.in sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ uidir = $(datadir)/gnome-2.0/ui ui_DATA = GNOME_ClockApplet.xml -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_ClockApplet_Factory.server.in -server_DATA = $(server_in_files:.server.in=.server) +servicedir = $(datadir)/dbus-1/services +service_in_files = org.gnome.panel.applet.Clock.service.in +service_DATA = $(service_in_files:.service.in=.service) -@INTLTOOL_SERVER_RULE@ +@INTLTOOL_SERVICE_RULE@ schemasdir = $(GCONF_SCHEMA_FILE_DIR) schemas_in_files = clock.schemas.in @@ -59,8 +59,8 @@ endif EXTRA_DIST = \ - GNOME_ClockApplet_Factory.server.in.in \ + org.gnome.panel.applet.Clock.service.in.in \ $(schemas_in_files) \ $(ui_DATA) -CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA) +CLEANFILES = $(service_in_files) $(service_DATA) $(schemas_DATA) Index: applets/clock/clock.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v retrieving revision 1.179 diff -u -u -r1.179 clock.c --- applets/clock/clock.c 28 Dec 2005 21:12:56 -0000 1.179 +++ applets/clock/clock.c 30 Dec 2005 18:06:53 -0000 @@ -50,11 +50,12 @@ #include #include +#include #include #include +#include #include -#include #include #include #include @@ -165,15 +166,13 @@ static void set_atk_name_description (GtkWidget *widget, const char *name, const char *desc); -static void display_properties_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname); -static void display_help_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname); -static void display_about_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname); + +static void display_properties_dialog (GtkAction *action, + ClockData *cd); +static void display_help_dialog (GtkAction *action, + ClockData *cd); +static void display_about_dialog (GtkAction *action, + ClockData *cd); static void position_calendar_popup (ClockData *cd, GtkWidget *window, GtkWidget *button); @@ -1339,7 +1338,7 @@ update_frame_visibility (cd->appointment_list, GTK_TREE_MODEL (cd->appointments_model)); switch (cd->orient) { - case PANEL_APPLET_ORIENT_UP: + case PANEL_APPLET_ORIENT_DOWN: gtk_box_pack_start (GTK_BOX (vbox), cd->appointment_list, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), cd->task_list, TRUE, TRUE, 0); break; @@ -1429,7 +1428,7 @@ gtk_calendar_select_day (GTK_CALENDAR (cd->calendar), tm->tm_mday); switch (cd->orient) { - case PANEL_APPLET_ORIENT_UP: + case PANEL_APPLET_ORIENT_DOWN: add_appointments_and_tasks (cd, vbox); gtk_box_pack_start (GTK_BOX (vbox), cd->calendar, TRUE, FALSE, 0); break; @@ -1492,11 +1491,9 @@ /* Based on panel orientation, position the popup. * Ignore window gravity since the window is undecorated. - * The orientations are all named backward from what - * I expected. */ switch (cd->orient) { - case PANEL_APPLET_ORIENT_RIGHT: + case PANEL_APPLET_ORIENT_LEFT: x += button_w; if ((y + h) > monitor.y + monitor.height) y -= (y + h) - (monitor.y + monitor.height); @@ -1507,7 +1504,7 @@ gravity = GDK_GRAVITY_NORTH_WEST; break; - case PANEL_APPLET_ORIENT_LEFT: + case PANEL_APPLET_ORIENT_RIGHT: x -= w; if ((y + h) > monitor.y + monitor.height) y -= (y + h) - (monitor.y + monitor.height); @@ -1518,7 +1515,7 @@ gravity = GDK_GRAVITY_NORTH_EAST; break; - case PANEL_APPLET_ORIENT_DOWN: + case PANEL_APPLET_ORIENT_UP: y += button_h; if ((x + w) > monitor.x + monitor.width) x -= (x + w) - (monitor.x + monitor.width); @@ -1526,7 +1523,7 @@ gravity = GDK_GRAVITY_NORTH_WEST; break; - case PANEL_APPLET_ORIENT_UP: + case PANEL_APPLET_ORIENT_DOWN: y -= h; if ((x + w) > monitor.x + monitor.width) x -= (x + w) - (monitor.x + monitor.width); @@ -1678,9 +1675,9 @@ /* Initialize label orientation */ if (cd->orient == PANEL_APPLET_ORIENT_RIGHT) - gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); - else if (cd->orient == PANEL_APPLET_ORIENT_LEFT) gtk_label_set_angle (GTK_LABEL (cd->clockw), 270); + else if (cd->orient == PANEL_APPLET_ORIENT_LEFT) + gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); else gtk_label_set_angle (GTK_LABEL (cd->clockw), 0); @@ -1707,9 +1704,9 @@ cd->orient = orient; if (cd->orient == PANEL_APPLET_ORIENT_RIGHT) - gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); - else if (cd->orient == PANEL_APPLET_ORIENT_LEFT) gtk_label_set_angle (GTK_LABEL (cd->clockw), 270); + else if (cd->orient == PANEL_APPLET_ORIENT_LEFT) + gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); else gtk_label_set_angle (GTK_LABEL (cd->clockw), 0); @@ -1732,9 +1729,8 @@ } static void -copy_time (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname) +copy_time (GtkAction *action, + ClockData *cd) { char string[256]; char *utf8; @@ -1788,9 +1784,8 @@ } static void -copy_date (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname) +copy_date (GtkAction *action, + ClockData *cd) { struct tm *tm; char string[256]; @@ -1873,9 +1868,8 @@ } static void -config_date (BonoboUIComponent *uic, - ClockData *cd, - const char *verbname) +config_date (GtkAction *action, + ClockData *cd) { GtkWidget *dialog; GdkScreen *screen; @@ -1906,15 +1900,25 @@ gtk_widget_show_all (dialog); } -/* current timestamp */ -static const BonoboUIVerb clock_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ClockPreferences", display_properties_dialog), - BONOBO_UI_UNSAFE_VERB ("ClockHelp", display_help_dialog), - BONOBO_UI_UNSAFE_VERB ("ClockAbout", display_about_dialog), - BONOBO_UI_UNSAFE_VERB ("ClockCopyTime", copy_time), - BONOBO_UI_UNSAFE_VERB ("ClockCopyDate", copy_date), - BONOBO_UI_UNSAFE_VERB ("ClockConfig", config_date), - BONOBO_UI_VERB_END +static const GtkActionEntry clock_menu_actions [] = { + { "ClockPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), + NULL, NULL, + G_CALLBACK (display_properties_dialog) }, + { "ClockHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (display_help_dialog) }, + { "ClockAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (display_about_dialog) }, + { "ClockCopyTime", GTK_STOCK_COPY, N_("Copy _Time"), + NULL, NULL, + G_CALLBACK (copy_time) }, + { "ClockCopyDate", GTK_STOCK_COPY, N_("Copy _Date"), + NULL, NULL, + G_CALLBACK (copy_date) }, + { "ClockConfig", GTK_STOCK_PREFERENCES, N_("Ad_just Date & Time"), + NULL, NULL, + G_CALLBACK (config_date) }, }; static void @@ -1925,7 +1929,7 @@ { const char *value; int new_format; - + if (!entry->value || entry->value->type != GCONF_VALUE_STRING) return; @@ -1941,9 +1945,9 @@ static void show_seconds_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - ClockData *clock) + guint cnxn_id, + GConfEntry *entry, + ClockData *clock) { gboolean value; @@ -2200,11 +2204,12 @@ fill_clock_applet (PanelApplet *applet) { ClockData *cd; - BonoboUIComponent *popup_component; + PanelAppletMenu *popup_menu; + GtkAction *action; GError *error; int format; char *format_str; - + panel_applet_add_preferences (applet, "/schemas/apps/clock_applet/prefs", NULL); panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR); @@ -2277,25 +2282,24 @@ panel_applet_set_background_widget (PANEL_APPLET (cd->applet), GTK_WIDGET (cd->applet)); - panel_applet_setup_menu_from_file (PANEL_APPLET (cd->applet), - NULL, - "GNOME_ClockApplet.xml", - NULL, - clock_menu_verbs, - cd); - - popup_component = panel_applet_get_popup_component (PANEL_APPLET (cd->applet)); + popup_menu = panel_applet_get_menu (PANEL_APPLET (cd->applet)); + + panel_applet_menu_add_actions (popup_menu, + clock_menu_actions, + G_N_ELEMENTS (clock_menu_actions), + cd); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_ClockApplet.xml", + NULL); if (panel_applet_get_locked_down (PANEL_APPLET (cd->applet))) { - bonobo_ui_component_set_prop (popup_component, - "/commands/ClockPreferences", - "hidden", "1", - NULL); - bonobo_ui_component_set_prop (popup_component, - "/commands/ClockConfig", - "hidden", "1", - NULL); - } + action = panel_applet_menu_get_action (popup_menu, "ClockPreferences"); + gtk_action_set_visible (action, FALSE); + + action = panel_applet_menu_get_action (popup_menu, "ClockConfig"); + gtk_action_set_visible (action, FALSE); + } if (!check_config_tool_command (cd->config_tool)) { g_free (cd->config_tool); @@ -2312,10 +2316,8 @@ } } - bonobo_ui_component_set_prop (popup_component, - "/commands/ClockConfig", - "hidden", cd->config_tool ? "0" : "1", - NULL); + action = panel_applet_menu_get_action (popup_menu, "ClockConfig"); + gtk_action_set_visible (action, (cd->config_tool != NULL)); return TRUE; } @@ -2504,9 +2506,8 @@ } static void -display_properties_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname) +display_properties_dialog (GtkAction *action, + ClockData *cd) { GtkWidget *hbox; GtkWidget *vbox; @@ -2637,9 +2638,8 @@ } static void -display_help_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname) +display_help_dialog (GtkAction *action, + ClockData *cd) { GError *error = NULL; static GnomeProgram *applet_program = NULL; @@ -2678,9 +2678,8 @@ } static void -display_about_dialog (BonoboUIComponent *uic, - ClockData *cd, - const gchar *verbname) +display_about_dialog (GtkAction *action, + ClockData *cd) { static const gchar *authors[] = { @@ -2730,15 +2729,15 @@ { gboolean retval = FALSE; - if (!strcmp (iid, "OAFIID:GNOME_ClockApplet")) - retval = fill_clock_applet (applet); + if (!strcmp (iid, "Clock")) + retval = fill_clock_applet (applet); return retval; } -PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_ClockApplet_Factory", - PANEL_TYPE_APPLET, - "ClockApplet", - "0", - clock_factory, - NULL); +PANEL_APPLET_FACTORY_MAIN ("Clock", + PANEL_TYPE_APPLET, + "Clock", + "0", + clock_factory, + NULL); Index: applets/clock/org.gnome.panel.applet.Clock.service.in.in =================================================================== RCS file: applets/clock/org.gnome.panel.applet.Clock.service.in.in diff -N applets/clock/org.gnome.panel.applet.Clock.service.in.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ applets/clock/org.gnome.panel.applet.Clock.service.in.in 30 Dec 2005 18:06:53 -0000 @@ -0,0 +1,9 @@ +# ClockApplet service +[D-BUS Service] +Name=org.gnome.panel.applet.Clock +Exec=@LIBEXECDIR@/clock-applet + +[Clock] +_Name=Clock +_Comment=Get the current time and date +Icon=clock.png Index: applets/fish/GNOME_FishApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/fish/GNOME_FishApplet.xml,v retrieving revision 1.5 diff -u -u -r1.5 GNOME_FishApplet.xml --- applets/fish/GNOME_FishApplet.xml 11 Jun 2004 10:53:16 -0000 1.5 +++ applets/fish/GNOME_FishApplet.xml 30 Dec 2005 18:06:53 -0000 @@ -1,12 +1,8 @@ - - - - - - - - - + + + + + + + + Index: applets/fish/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/fish/Makefile.am,v retrieving revision 1.42 diff -u -u -r1.42 Makefile.am --- applets/fish/Makefile.am 30 Oct 2004 21:04:57 -0000 1.42 +++ applets/fish/Makefile.am 30 Dec 2005 18:06:53 -0000 @@ -23,12 +23,12 @@ footguy.png \ monkey.png -EXTRA_DIST = \ - $(FISH_BITMAPS) \ - GNOME_FishApplet_Factory.server.in.in \ - gnome-fish.png \ - fish.schemas.in \ - $(ui_DATA) \ +EXTRA_DIST = \ + $(FISH_BITMAPS) \ + org.gnome.panel.applet.Fish.service.in.in \ + gnome-fish.png \ + fish.schemas.in \ + $(ui_DATA) \ $(glade_DATA) gladedir = $(datadir)/gnome/panel/glade @@ -43,16 +43,16 @@ uidir = $(datadir)/gnome-2.0/ui ui_DATA = GNOME_FishApplet.xml -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_FishApplet_Factory.server.in -server_DATA = $(server_in_files:.server.in=.server) +servicedir = $(datadir)/dbus-1/services +service_in_files = org.gnome.panel.applet.Fish.service.in +service_DATA = $(service_in_files:.service.in=.service) -$(server_in_files): $(server_in_files).in +org.gnome.panel.applet.Fish.service.in: org.gnome.panel.applet.Fish.service.in.in sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -CLEANFILES = $(server_DATA) $(server_DATA).in $(schemas_DATA) +CLEANFILES = $(service_DATA) $(service_DATA).in $(schemas_DATA) -@INTLTOOL_SERVER_RULE@ +@INTLTOOL_SERVICE_RULE@ schemasdir = $(GCONF_SCHEMA_FILE_DIR) schemas_in_files = fish.schemas.in Index: applets/fish/fish.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/fish/fish.c,v retrieving revision 1.133 diff -u -u -r1.133 fish.c --- applets/fish/fish.c 28 Dec 2005 21:14:15 -0000 1.133 +++ applets/fish/fish.c 30 Dec 2005 18:06:53 -0000 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -380,10 +381,9 @@ have_preview); } -static void -display_preferences_dialog (BonoboUIComponent *uic, - FishApplet *fish, - const char *verbname) +static void +display_preferences_dialog (GtkAction *action, + FishApplet *fish) { GladeXML *xml; GtkWidget *button; @@ -530,17 +530,15 @@ } static void -display_help_dialog (BonoboUIComponent *uic, - FishApplet *fish, - const char *verbname) +display_help_dialog (GtkAction *action, + FishApplet *fish) { show_help (fish, NULL); } static void -display_about_dialog (BonoboUIComponent *uic, - FishApplet *fish, - const char *verbname) +display_about_dialog (GtkAction *action, + FishApplet *fish) { const char *author_format = _("%s the Fish"); const char *about_format = _("%s has no use what-so-ever. " @@ -1768,12 +1766,16 @@ gtk_widget_show_all (widget); } -static const BonoboUIVerb fish_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("FishPreferences", display_preferences_dialog), - BONOBO_UI_UNSAFE_VERB ("FishHelp", display_help_dialog), - BONOBO_UI_UNSAFE_VERB ("FishAbout", display_about_dialog), - - BONOBO_UI_VERB_END +static const GtkActionEntry fish_menu_actions [] = { + { "FishPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), + NULL, NULL, + G_CALLBACK (display_preferences_dialog) }, + { "FishHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (display_help_dialog) }, + { "FishAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (display_about_dialog) }, }; static void @@ -1795,8 +1797,9 @@ static gboolean fish_applet_fill (FishApplet *fish) { - PanelApplet *applet = (PanelApplet *) fish; - GError *error = NULL; + PanelApplet *applet = (PanelApplet *) fish; + PanelAppletMenu *popup_menu; + GError *error = NULL; fish->orientation = panel_applet_get_orient (applet); @@ -1860,19 +1863,22 @@ fish->rotate = FALSE; /* Fallback */ } - panel_applet_setup_menu_from_file ( - applet, NULL, "GNOME_FishApplet.xml", - NULL, fish_menu_verbs, fish); + popup_menu = panel_applet_get_menu (PANEL_APPLET (applet)); - if (panel_applet_get_locked_down (applet)) { - BonoboUIComponent *popup_component; + panel_applet_menu_add_actions (popup_menu, + fish_menu_actions, + G_N_ELEMENTS (fish_menu_actions), + applet); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_FishApplet.xml", + NULL); - popup_component = panel_applet_get_popup_component (applet); + if (panel_applet_get_locked_down (applet)) { + GtkAction *action; - bonobo_ui_component_set_prop (popup_component, - "/commands/FishPreferences", - "hidden", "1", - NULL); + action = panel_applet_menu_get_action (popup_menu, "FishPreferences"); + gtk_action_set_visible (action, FALSE); } gtk_window_set_default_icon_name ("gnome-fish"); @@ -1888,7 +1894,7 @@ { gboolean retval = FALSE; - if (!strcmp (iid, "OAFIID:GNOME_FishApplet")) + if (!strcmp (iid, "Fish")) retval = fish_applet_fill (FISH_APPLET (applet)); return retval; @@ -2061,9 +2067,11 @@ return type; } -PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FishApplet_Factory", - fish_applet_get_type (), - "That-stupid-fish", - "0", - fishy_factory, - NULL) +PANEL_APPLET_FACTORY_MAIN ("Fish", + fish_applet_get_type (), + "That-stupid-fish", + "0", + fishy_factory, + NULL) + + Index: applets/fish/org.gnome.panel.applet.Fish.service.in.in =================================================================== RCS file: applets/fish/org.gnome.panel.applet.Fish.service.in.in diff -N applets/fish/org.gnome.panel.applet.Fish.service.in.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ applets/fish/org.gnome.panel.applet.Fish.service.in.in 30 Dec 2005 18:06:53 -0000 @@ -0,0 +1,9 @@ +# FishApplet service +[D-BUS Service] +Name=org.gnome.panel.applet.Fish +Exec=@LIBEXECDIR@/fish-applet-2 + +[Fish] +_Name=Fish +_Comment=Display a swimming fish or another animated creature +Icon=gnome-fish.png Index: applets/notification_area/GNOME_NotificationAreaApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/notification_area/GNOME_NotificationAreaApplet.xml,v retrieving revision 1.2 diff -u -u -r1.2 GNOME_NotificationAreaApplet.xml --- applets/notification_area/GNOME_NotificationAreaApplet.xml 11 Jun 2004 10:53:16 -0000 1.2 +++ applets/notification_area/GNOME_NotificationAreaApplet.xml 30 Dec 2005 18:06:53 -0000 @@ -1,10 +1,7 @@ - - - - - - - - + + + + + + + Index: applets/notification_area/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/notification_area/Makefile.am,v retrieving revision 1.8 diff -u -u -r1.8 Makefile.am --- applets/notification_area/Makefile.am 30 Oct 2004 21:04:57 -0000 1.8 +++ applets/notification_area/Makefile.am 30 Dec 2005 18:06:54 -0000 @@ -35,20 +35,20 @@ $(X_LIBS) \ $(PANEL_LIBS) -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_NotificationAreaApplet.server.in -server_DATA = GNOME_NotificationAreaApplet.server - -GNOME_NotificationAreaApplet.server.in: $(srcdir)/GNOME_NotificationAreaApplet.server.in.in +org.gnome.panel.applet.NotificationArea.service.in: org.gnome.panel.applet.NotificationArea.service.in.in sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ +servicedir = $(datadir)/dbus-1/services +service_in_files = org.gnome.panel.applet.NotificationArea.service.in +service_DATA = $(service_in_files:.service.in=.service) + +@INTLTOOL_SERVICE_RULE@ uidir = $(datadir)/gnome-2.0/ui ui_DATA = GNOME_NotificationAreaApplet.xml EXTRA_DIST = \ - GNOME_NotificationAreaApplet.server.in.in \ + org.gnome.panel.applet.NotificationArea.service.in.in \ $(ui_DATA) \ update-from-egg.sh \ eggmarshalers.list @@ -57,9 +57,7 @@ BUILT_SOURCES = eggmarshalers.c eggmarshalers.h -CLEANFILES = \ - GNOME_NotificationAreaApplet.server.in \ - GNOME_NotificationAreaApplet.server +CLEANFILES = $(service_in_files) $(service_DATA) regenerate-built-sources: EGGFILES="$(EGGFILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh Index: applets/notification_area/main.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/notification_area/main.c,v retrieving revision 1.30 diff -u -u -r1.30 main.c --- applets/notification_area/main.c 28 Dec 2005 21:15:27 -0000 1.30 +++ applets/notification_area/main.c 30 Dec 2005 18:06:54 -0000 @@ -24,14 +24,13 @@ #include #include +#include #include #include #include #include -#include - #include "eggtraymanager.h" #include "fixedtip.h" #include "obox.h" @@ -59,9 +58,8 @@ } SystemTray; static void -help_cb (BonoboUIComponent *uic, - SystemTray *tray, - const gchar *verbname) +help_cb (GtkAction *action, + SystemTray *tray) { GError *err; @@ -96,11 +94,9 @@ } } - static void -about_cb (BonoboUIComponent *uic, - SystemTray *tray, - const gchar *verbname) +about_cb (GtkAction *action, + SystemTray *tray) { GdkScreen *screen; @@ -142,10 +138,13 @@ gtk_widget_show (tray->about_dialog); } -static const BonoboUIVerb menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("SystemTrayHelp", help_cb), - BONOBO_UI_UNSAFE_VERB ("SystemTrayAbout", about_cb), - BONOBO_UI_VERB_END +static const GtkActionEntry menu_actions [] = { + { "SystemTrayHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (help_cb) }, + { "SystemTrayAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (about_cb) }, }; static void @@ -266,11 +265,12 @@ const gchar *iid, gpointer data) { - SystemTray *tray; - AtkObject *atko; + SystemTray *tray; + AtkObject *atko; + PanelAppletMenu *popup_menu; - if (!(strcmp (iid, "OAFIID:GNOME_NotificationAreaApplet") == 0 || - strcmp (iid, "OAFIID:GNOME_SystemTrayApplet") == 0)) + if (!(strcmp (iid, "NotificationArea") == 0 || + strcmp (iid, "SystemTrayApplet") == 0)) return FALSE; if (tray_manager == NULL) @@ -347,25 +347,27 @@ 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), - NULL, - "GNOME_NotificationAreaApplet.xml", - NULL, - menu_verbs, - tray); - + + popup_menu = panel_applet_get_menu (PANEL_APPLET (tray->applet)); + + panel_applet_menu_add_actions (popup_menu, + menu_actions, + G_N_ELEMENTS (menu_actions), + tray); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_NotificationAreaApplet.xml", + NULL); return TRUE; } #if 1 -PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory", - PANEL_TYPE_APPLET, - "NotificationArea", - "0", - applet_factory, - NULL) - +PANEL_APPLET_FACTORY_MAIN ("NotificationArea", + PANEL_TYPE_APPLET, + "NotificationArea", + "0", + applet_factory, + NULL) #else PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory", Index: applets/notification_area/org.gnome.panel.applet.NotificationArea.service.in.in =================================================================== RCS file: applets/notification_area/org.gnome.panel.applet.NotificationArea.service.in.in diff -N applets/notification_area/org.gnome.panel.applet.NotificationArea.service.in.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ applets/notification_area/org.gnome.panel.applet.NotificationArea.service.in.in 30 Dec 2005 18:06:54 -0000 @@ -0,0 +1,8 @@ +[D-BUS Service] +Name=org.gnome.panel.applet.NotificationArea +Exec=@LIBEXECDIR@/notification-area-applet + +[NotificationArea] +_Name=Notification Area +_Comment=Area where notification icons appear +Icon=panel-notification-area.png Index: applets/wncklet/GNOME_ShowDesktopApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/GNOME_ShowDesktopApplet.xml,v retrieving revision 1.2 diff -u -u -r1.2 GNOME_ShowDesktopApplet.xml --- applets/wncklet/GNOME_ShowDesktopApplet.xml 11 Jun 2004 10:53:17 -0000 1.2 +++ applets/wncklet/GNOME_ShowDesktopApplet.xml 30 Dec 2005 18:06:54 -0000 @@ -1,10 +1,6 @@ - - - - - - - - + + + + + + Index: applets/wncklet/GNOME_WindowListApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/GNOME_WindowListApplet.xml,v retrieving revision 1.4 diff -u -u -r1.4 GNOME_WindowListApplet.xml --- applets/wncklet/GNOME_WindowListApplet.xml 11 Jun 2004 10:53:17 -0000 1.4 +++ applets/wncklet/GNOME_WindowListApplet.xml 30 Dec 2005 18:06:54 -0000 @@ -1,15 +1,10 @@ - - - - - - - - - + + + + + + + Index: applets/wncklet/GNOME_WindowMenuApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/GNOME_WindowMenuApplet.xml,v retrieving revision 1.2 diff -u -u -r1.2 GNOME_WindowMenuApplet.xml --- applets/wncklet/GNOME_WindowMenuApplet.xml 11 Jun 2004 10:53:17 -0000 1.2 +++ applets/wncklet/GNOME_WindowMenuApplet.xml 30 Dec 2005 18:06:54 -0000 @@ -1,10 +1,6 @@ - - - - - - - - + + + + + + Index: applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml,v retrieving revision 1.5 diff -u -u -r1.5 GNOME_WorkspaceSwitcherApplet.xml --- applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml 11 Jun 2004 10:53:17 -0000 1.5 +++ applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml 30 Dec 2005 18:06:54 -0000 @@ -1,14 +1,9 @@ - - - - - - - - - + + + + + + + Index: applets/wncklet/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/Makefile.am,v retrieving revision 1.16 diff -u -u -r1.16 Makefile.am --- applets/wncklet/Makefile.am 29 Jan 2005 00:08:01 -0000 1.16 +++ applets/wncklet/Makefile.am 30 Dec 2005 18:06:54 -0000 @@ -35,21 +35,21 @@ $(WNCKLET_LIBS) EXTRA_DIST = \ - GNOME_Wncklet_Factory.server.in.in \ + org.gnome.panel.applet.Wncklet.service.in.in \ $(ui_DATA) \ $(schemas_in_files) \ $(glade_DATA) -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_Wncklet_Factory.server.in -server_DATA = $(server_in_files:.server.in=.server) +org.gnome.panel.applet.Wncklet.service.in: org.gnome.panel.applet.Wncklet.service.in.in + sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -$(server_in_files): $(server_in_files).in - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ +servicedir = $(datadir)/dbus-1/services +service_in_files = org.gnome.panel.applet.Wncklet.service.in +service_DATA = $(service_in_files:.service.in=.service) -@INTLTOOL_SERVER_RULE@ +@INTLTOOL_SERVICE_RULE@ -CLEANFILES = $(server_in_files) $(server_DATA) $(BUILT_SOURCES) $(schemas_DATA) +CLEANFILES = $(service_in_files) $(service_DATA) $(BUILT_SOURCES) $(schemas_DATA) uidir = $(datadir)/gnome-2.0/ui ui_DATA = \ Index: applets/wncklet/org.gnome.panel.applet.Wncklet.service.in.in =================================================================== RCS file: applets/wncklet/org.gnome.panel.applet.Wncklet.service.in.in diff -N applets/wncklet/org.gnome.panel.applet.Wncklet.service.in.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ applets/wncklet/org.gnome.panel.applet.Wncklet.service.in.in 30 Dec 2005 18:06:54 -0000 @@ -0,0 +1,24 @@ +[D-BUS Service] +Name=org.gnome.panel.applet.Wncklet +Exec=@LIBEXECDIR@/wnck-applet + +[WindowMenu] +_Name=Window Selector +_Comment=Switch between open windows using a menu +Icon=panel-window-menu.png + +[WorkspaceSwitcher] +_Name=Workspace Switcher +_Comment=Switch between workspaces +Icon=gnome-workspace.png + +[WindowList] +_Name=Window List +_Comment=Switch between open windows using buttons +Icon=panel-window-list.png + +[ShowDesktop] +_Name=Show Desktop +_Comment=Hide application windows and show the desktop +Icon=gnome-fs-desktop.png + Index: applets/wncklet/showdesktop.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/showdesktop.c,v retrieving revision 1.32 diff -u -u -r1.32 showdesktop.c --- applets/wncklet/showdesktop.c 28 Dec 2005 21:18:36 -0000 1.32 +++ applets/wncklet/showdesktop.c 30 Dec 2005 18:06:54 -0000 @@ -63,12 +63,10 @@ GtkIconTheme *icon_theme; } ShowDesktopData; -static void display_help_dialog (BonoboUIComponent *uic, - ShowDesktopData *sdd, - const gchar *verbname); -static void display_about_dialog (BonoboUIComponent *uic, - ShowDesktopData *sdd, - const gchar *verbname); +static void display_help_dialog (GtkAction *action, + ShowDesktopData *sdd); +static void display_about_dialog (GtkAction *action, + ShowDesktopData *sdd); static void update_icon (ShowDesktopData *sdd); static void update_button_state (ShowDesktopData *sdd); @@ -202,10 +200,13 @@ g_object_unref (icon); } -static const BonoboUIVerb show_desktop_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ShowDesktopHelp", display_help_dialog), - BONOBO_UI_UNSAFE_VERB ("ShowDesktopAbout", display_about_dialog), - BONOBO_UI_VERB_END +static const GtkActionEntry show_desktop_menu_actions [] = { + { "ShowDesktopHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (display_help_dialog) }, + { "ShowDesktopAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (display_about_dialog) }, }; /* This updates things that should be consistent with the button's appearance, @@ -386,6 +387,7 @@ show_desktop_applet_fill (PanelApplet *applet) { ShowDesktopData *sdd; + PanelAppletMenu *popup_menu; AtkObject *atk_obj; panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR); @@ -444,12 +446,16 @@ panel_applet_set_background_widget (PANEL_APPLET (sdd->applet), GTK_WIDGET (sdd->applet)); - panel_applet_setup_menu_from_file (PANEL_APPLET (sdd->applet), - NULL, - "GNOME_ShowDesktopApplet.xml", - NULL, - show_desktop_menu_verbs, - sdd); + popup_menu = panel_applet_get_menu (PANEL_APPLET (sdd->applet)); + + panel_applet_menu_add_actions (popup_menu, + show_desktop_menu_actions, + G_N_ELEMENTS (show_desktop_menu_actions), + sdd); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_ShowDesktopApplet.xml", + NULL); g_signal_connect (G_OBJECT (sdd->applet), "destroy", @@ -471,18 +477,16 @@ } static void -display_help_dialog (BonoboUIComponent *uic, - ShowDesktopData *sdd, - const gchar *verbname) +display_help_dialog (GtkAction *action, + ShowDesktopData *sdd) { wncklet_display_help (sdd->applet, "user-guide", "user-guide.xml", "gospanel-564"); } static void -display_about_dialog (BonoboUIComponent *uic, - ShowDesktopData *sdd, - const gchar *verbname) +display_about_dialog (GtkAction *action, + ShowDesktopData *sdd) { static const gchar *authors[] = { "Havoc Pennington ", Index: applets/wncklet/window-list.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/window-list.c,v retrieving revision 1.76 diff -u -u -r1.76 window-list.c --- applets/wncklet/window-list.c 28 Dec 2005 21:18:36 -0000 1.76 +++ applets/wncklet/window-list.c 30 Dec 2005 18:06:54 -0000 @@ -16,7 +16,6 @@ #include -#include #include #include @@ -64,15 +63,12 @@ guint listeners [5]; } TasklistData; -static void display_properties_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname); -static void display_help_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname); -static void display_about_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname); +static void display_properties_dialog (GtkAction *action, + TasklistData *tasklist); +static void display_help_dialog (GtkAction *action, + TasklistData *tasklist); +static void display_about_dialog (GtkAction *action, + TasklistData *tasklist); static void tasklist_update (TasklistData *tasklist) @@ -246,11 +242,16 @@ g_free (tasklist); } -static const BonoboUIVerb tasklist_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("TasklistPreferences", display_properties_dialog), - BONOBO_UI_UNSAFE_VERB ("TasklistHelp", display_help_dialog), - BONOBO_UI_UNSAFE_VERB ("TasklistAbout", display_about_dialog), - BONOBO_UI_VERB_END +static const GtkActionEntry tasklist_menu_actions [] = { + { "TasklistPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), + NULL, NULL, + G_CALLBACK (display_properties_dialog) }, + { "TasklistHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (display_help_dialog) }, + { "TasklistAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (display_about_dialog) }, }; static void @@ -611,6 +612,7 @@ window_list_applet_fill (PanelApplet *applet) { TasklistData *tasklist; + PanelAppletMenu *popup_menu; GError *error; GConfValue *value; @@ -730,26 +732,26 @@ "change_background", G_CALLBACK (applet_change_background), tasklist); - + panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet), GTK_WIDGET (tasklist->applet)); - - panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet), - NULL, - "GNOME_WindowListApplet.xml", - NULL, - tasklist_menu_verbs, - tasklist); - if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) { - BonoboUIComponent *popup_component; + popup_menu = panel_applet_get_menu (PANEL_APPLET (tasklist->applet)); - popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet)); + panel_applet_menu_add_actions (popup_menu, + tasklist_menu_actions, + G_N_ELEMENTS (tasklist_menu_actions), + tasklist); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_WindowListApplet.xml", + NULL); - bonobo_ui_component_set_prop (popup_component, - "/commands/TasklistPreferences", - "hidden", "1", - NULL); + if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) { + GtkAction *action; + + action = panel_applet_menu_get_action (popup_menu, "TasklistPreferences"); + gtk_action_set_visible (action, FALSE); } gtk_widget_show (tasklist->applet); @@ -759,18 +761,16 @@ static void -display_help_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname) +display_help_dialog (GtkAction *action, + TasklistData *tasklist) { wncklet_display_help (tasklist->applet, "window-list", "window-list", NULL); } static void -display_about_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname) +display_about_dialog (GtkAction *action, + TasklistData *tasklist) { static const gchar *authors[] = { @@ -1011,12 +1011,9 @@ g_object_unref (G_OBJECT (client)); } - - -static void -display_properties_dialog (BonoboUIComponent *uic, - TasklistData *tasklist, - const gchar *verbname) +static void +display_properties_dialog (GtkAction *action, + TasklistData *tasklist) { if (tasklist->properties_dialog == NULL) { GladeXML *xml; Index: applets/wncklet/window-menu.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/window-menu.c,v retrieving revision 1.39 diff -u -u -r1.39 window-menu.c --- applets/wncklet/window-menu.c 28 Dec 2005 21:18:36 -0000 1.39 +++ applets/wncklet/window-menu.c 30 Dec 2005 18:06:54 -0000 @@ -49,18 +49,16 @@ } WindowMenu; static void -window_menu_help (BonoboUIComponent *uic, - WindowMenu *window_menu, - const char *verb) +window_menu_help (GtkAction *action, + WindowMenu *window_menu) { wncklet_display_help (window_menu->applet, "user-guide", "user-guide.xml", "gosmetacity-27"); } static void -window_menu_about (BonoboUIComponent *uic, - WindowMenu *window_menu, - const char *verb) +window_menu_about (GtkAction *action, + WindowMenu *window_menu) { static const char *authors[] = { "Mark McLoughlin ", @@ -88,11 +86,13 @@ "WindowMenu"); } -static const BonoboUIVerb window_menu_verbs [] = -{ - BONOBO_UI_UNSAFE_VERB ("WindowMenuHelp", window_menu_help), - BONOBO_UI_UNSAFE_VERB ("WindowMenuAbout", window_menu_about), - BONOBO_UI_VERB_END +static const GtkActionEntry window_menu_actions [] = { + { "WindowMenuHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (window_menu_help) }, + { "WindowMenuAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (window_menu_about) }, }; static void @@ -231,8 +231,9 @@ gboolean window_menu_applet_fill (PanelApplet *applet) { - WindowMenu *window_menu; - WnckScreen *screen; + WindowMenu *window_menu; + WnckScreen *screen; + PanelAppletMenu *popup_menu; window_menu = g_new0 (WindowMenu, 1); @@ -247,8 +248,16 @@ g_signal_connect (window_menu->applet, "destroy", G_CALLBACK (window_menu_destroy), window_menu); - panel_applet_setup_menu_from_file (applet, NULL, "GNOME_WindowMenuApplet.xml", - NULL, window_menu_verbs, window_menu); + popup_menu = panel_applet_get_menu (PANEL_APPLET (window_menu->applet)); + + panel_applet_menu_add_actions (popup_menu, + window_menu_actions, + G_N_ELEMENTS (window_menu_actions), + window_menu); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_WindowMenuApplet.xml", + NULL); screen = wncklet_get_screen (window_menu->applet); window_menu->selector = wnck_selector_new (screen); Index: applets/wncklet/wncklet.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/wncklet.c,v retrieving revision 1.7 diff -u -u -r1.7 wncklet.c --- applets/wncklet/wncklet.c 28 Dec 2005 21:18:36 -0000 1.7 +++ applets/wncklet/wncklet.c 30 Dec 2005 18:06:54 -0000 @@ -26,7 +26,6 @@ #endif #include -#include #include #include #include @@ -173,27 +172,27 @@ { gboolean retval = FALSE; - if (!strcmp (iid, "OAFIID:GNOME_WindowMenuApplet")) + if (!strcmp (iid, "WindowMenu")) retval = window_menu_applet_fill (applet); - else if (!strcmp (iid, "OAFIID:GNOME_WorkspaceSwitcherApplet")|| - !strcmp (iid, "OAFIID:GNOME_PagerApplet")) + else if (!strcmp (iid, "WorkspaceSwitcher")|| + !strcmp (iid, "PagerApplet")) retval = workspace_switcher_applet_fill (applet); - else if (!strcmp (iid, "OAFIID:GNOME_WindowListApplet") || - !strcmp (iid, "OAFIID:GNOME_TasklistApplet")) + else if (!strcmp (iid, "WindowList") || + !strcmp (iid, "TasklistApplet")) retval = window_list_applet_fill (applet); - else if (!strcmp (iid, "OAFIID:GNOME_ShowDesktopApplet")) + else if (!strcmp (iid, "ShowDesktop")) retval = show_desktop_applet_fill (applet); return retval; } +PANEL_APPLET_FACTORY_MAIN ("Wncklet", + PANEL_TYPE_APPLET, + "WindowNavigationApplets", + "0", + wncklet_factory, + NULL); -PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Wncklet_Factory", - PANEL_TYPE_APPLET, - "WindowNavigationApplets", - "0", - wncklet_factory, - NULL); Index: applets/wncklet/wncklet.h =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/wncklet.h,v retrieving revision 1.3 diff -u -u -r1.3 wncklet.h --- applets/wncklet/wncklet.h 28 Dec 2005 21:18:36 -0000 1.3 +++ applets/wncklet/wncklet.h 30 Dec 2005 18:06:54 -0000 @@ -29,7 +29,9 @@ #include #include + #include +#include G_BEGIN_DECLS Index: applets/wncklet/workspace-switcher.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/workspace-switcher.c,v retrieving revision 1.75 diff -u -u -r1.75 workspace-switcher.c --- applets/wncklet/workspace-switcher.c 28 Dec 2005 21:18:36 -0000 1.75 +++ applets/wncklet/workspace-switcher.c 30 Dec 2005 18:06:55 -0000 @@ -16,7 +16,6 @@ #include -#include #include #include @@ -68,15 +67,12 @@ guint listeners [3]; } PagerData; -static void display_properties_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname); -static void display_help_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname); -static void display_about_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname); +static void display_properties_dialog (GtkAction *action, + PagerData *pager); +static void display_help_dialog (GtkAction *action, + PagerData *pager); +static void display_about_dialog (GtkAction *action, + PagerData *pager); static void pager_update (PagerData *pager) @@ -276,11 +272,16 @@ g_free (pager); } -static const BonoboUIVerb pager_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("PagerPreferences", display_properties_dialog), - BONOBO_UI_UNSAFE_VERB ("PagerHelp", display_help_dialog), - BONOBO_UI_UNSAFE_VERB ("PagerAbout", display_about_dialog), - BONOBO_UI_VERB_END +static const GtkActionEntry pager_menu_actions [] = { + { "PagerPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), + NULL, NULL, + G_CALLBACK (display_properties_dialog) }, + { "PagerHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (display_help_dialog) }, + { "PagerAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (display_about_dialog) }, }; static void @@ -407,6 +408,7 @@ workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; + PanelAppletMenu *popup_menu; GError *error; gboolean display_names; @@ -503,44 +505,41 @@ G_CALLBACK (applet_change_background), pager); - panel_applet_set_background_widget (PANEL_APPLET (pager->applet), - GTK_WIDGET (pager->applet)); - - panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet), - NULL, - "GNOME_WorkspaceSwitcherApplet.xml", - NULL, - pager_menu_verbs, - pager); + panel_applet_set_background_widget (PANEL_APPLET (pager->applet), + GTK_WIDGET (pager->applet)); - if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) { - BonoboUIComponent *popup_component; + popup_menu = panel_applet_get_menu (PANEL_APPLET (pager->applet)); - popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); + panel_applet_menu_add_actions (popup_menu, + pager_menu_actions, + G_N_ELEMENTS (pager_menu_actions), + pager); + panel_applet_menu_add_ui_from_file (popup_menu, + NULL, + "GNOME_WorkspaceSwitcherApplet.xml", + NULL); + + if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) { + GtkAction *action; - bonobo_ui_component_set_prop (popup_component, - "/commands/PagerPreferences", - "hidden", "1", - NULL); + action = panel_applet_menu_get_action (popup_menu, "PagerPreferences"); + gtk_action_set_visible (action, FALSE); } return TRUE; } - static void -display_help_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname) +display_help_dialog (GtkAction *action, + PagerData *pager) { wncklet_display_help (pager->applet, "workspace-switcher", "workspace-switcher", NULL); } static void -display_about_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname) +display_about_dialog (GtkAction *action, + PagerData *pager) { static const gchar *authors[] = { @@ -912,10 +911,9 @@ } } -static void -display_properties_dialog (BonoboUIComponent *uic, - PagerData *pager, - const gchar *verbname) +static void +display_properties_dialog (GtkAction *action, + PagerData *pager) { if (pager->properties_dialog == NULL) { GladeXML *xml; Index: gnome-panel/GNOME_Panel_Popup.xml =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/GNOME_Panel_Popup.xml,v retrieving revision 1.5 diff -u -u -r1.5 GNOME_Panel_Popup.xml --- gnome-panel/GNOME_Panel_Popup.xml 23 Jan 2005 17:09:28 -0000 1.5 +++ gnome-panel/GNOME_Panel_Popup.xml 30 Dec 2005 18:06:55 -0000 @@ -1,20 +1,7 @@ - - - + + + + + + - - - - - - - - - - - - - - Index: gnome-panel/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/Makefile.am,v retrieving revision 1.350 diff -u -u -r1.350 Makefile.am --- gnome-panel/Makefile.am 11 Apr 2005 14:58:40 -0000 1.350 +++ gnome-panel/Makefile.am 30 Dec 2005 18:06:55 -0000 @@ -6,6 +6,8 @@ INCLUDES = \ -I. \ -I$(srcdir) \ + -I$(srcdir)/../libpanel-applet \ + -I$(top_builddir)/libpanel-applet \ -I$(top_builddir)/gnome-panel \ -DPANEL_DEBUG \ -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ @@ -33,16 +35,11 @@ $(gnome_panel_OBJECTS): $(BUILT_SOURCES) -CORBA_SRCLIST = \ - GNOME_Panel-stubs.c \ - GNOME_Panel-skels.c \ - GNOME_Panel-common.c \ - GNOME_Panel.h \ - $(NULL) - -$(CORBA_SRCLIST): $(top_srcdir)/idl/GNOME_Panel.idl $(ORBIT_IDL) - $(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/idl/GNOME_Panel.idl +DBUS_SRCLIST = panel-shell-glue.h +panel-shell-glue.h: panel-shell.xml + dbus-binding-tool --prefix=panel_shell --mode=glib-server --output=$@ $^ + EGG_RECENT_FILES_C = \ egg-recent-model.c \ egg-recent-item.c \ @@ -63,7 +60,7 @@ $(NULL) BUILT_SOURCES = \ - $(CORBA_SRCLIST) \ + $(DBUS_SRCLIST) \ panel-typebuiltins.c \ panel-typebuiltins.h \ panel-marshal.c \ @@ -164,13 +161,14 @@ $(NULL) gnome_panel_SOURCES = \ - $(CORBA_SRCLIST) \ + $(DBUS_SRCLIST) \ $(EGG_ACCELERATORS_FILES) \ $(panel_sources) \ $(panel_headers) \ $(NULL) gnome_panel_LDADD = \ + ../libpanel-applet/libpanel-applet-2.la \ $(X_LIBS) \ $(PANEL_LIBS) \ -lpopt @@ -187,6 +185,7 @@ gnome_desktop_item_edit_LDFLAGS = -export-dynamic gnome_desktop_item_edit_LDADD = \ + ../libpanel-applet/libpanel-applet-2.la \ $(X_LIBS) \ $(PANEL_LIBS) \ -lpopt @@ -197,7 +196,6 @@ panel-run-dialog.glade EXTRA_DIST = \ - GNOME_Panel.server.in \ $(glade_DATA) \ nothing.cP \ nothing.h \ @@ -207,14 +205,14 @@ panel-marshal.list \ update-from-egg.sh \ gnome-panelrc \ - panel-default-setup.entries.in + panel-default-setup.entries.in \ + panel-shell.xml @INTLTOOL_DESKTOP_RULE@ panel_enum_headers = \ $(top_srcdir)/gnome-panel/panel-enums.h \ - $(top_srcdir)/gnome-panel/panel-types.h \ - GNOME_Panel.h + $(top_srcdir)/gnome-panel/panel-types.h panel-marshal.h: panel-marshal.list $(GLIB_GENMARSHAL) $(GLIB_GENMARSHAL) $< --header --prefix=panel_marshal > $@ @@ -252,10 +250,6 @@ uidir = $(datadir)/gnome-2.0/ui ui_DATA = GNOME_Panel_Popup.xml -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_Panel.server.in -server_DATA = $(server_in_files:.server.in=.server) - rcdir = $(datadir) rc_DATA = gnome-panelrc @@ -295,7 +289,6 @@ CLEANFILES = \ $(BUILT_SOURCES) \ $(schemas_in_files:.schemas.in=.schemas) \ - $(server_DATA) \ $(entries_DATA) \ $(sys_DATA) Index: gnome-panel/applet.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/applet.c,v retrieving revision 1.251 diff -u -u -r1.251 applet.c --- gnome-panel/applet.c 19 Nov 2005 14:49:09 -0000 1.251 +++ gnome-panel/applet.c 30 Dec 2005 18:06:55 -0000 @@ -55,7 +55,7 @@ case PANEL_OBJECT_LAUNCHER: panel_launcher_set_dnd_enabled (info->data, dnd_enabled); break; - case PANEL_OBJECT_BONOBO: + case PANEL_OBJECT_APPLET: break; case PANEL_OBJECT_LOGOUT: case PANEL_OBJECT_LOCK: @@ -69,7 +69,6 @@ g_assert_not_reached (); break; } - } gboolean @@ -191,7 +190,7 @@ panel_applet_toggle_locked (info); - if (info->type == PANEL_OBJECT_BONOBO) + if (info->type == PANEL_OBJECT_APPLET) panel_applet_frame_sync_menu_state (PANEL_APPLET_FRAME (info->widget)); else panel_applet_recreate_menu (info); @@ -264,7 +263,7 @@ PANEL_MENU_BAR (menu->info->widget), menu->name); break; - case PANEL_OBJECT_BONOBO: + case PANEL_OBJECT_APPLET: /* * Applet's menu's are handled differently */ @@ -673,7 +672,7 @@ if (panel_applet_is_in_drag ()) return FALSE; - if (info->type == PANEL_OBJECT_BONOBO) + if (info->type == PANEL_OBJECT_APPLET) return FALSE; applet_show_menu (info, event); @@ -734,7 +733,7 @@ } } - if (info->type != PANEL_OBJECT_BONOBO) + if (info->type != PANEL_OBJECT_APPLET) panel_lockdown_notify_remove (G_CALLBACK (panel_applet_recreate_menu), info); @@ -844,7 +843,7 @@ } switch (applet->type) { - case PANEL_OBJECT_BONOBO: + case PANEL_OBJECT_APPLET: panel_applet_frame_load_from_gconf ( panel_widget, applet->locked, @@ -1031,7 +1030,7 @@ client = panel_gconf_get_client (); - key_type = applet_info->type == PANEL_OBJECT_BONOBO ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; + key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; panel_widget = PANEL_WIDGET (applet_info->widget->parent); @@ -1173,11 +1172,11 @@ g_object_set_data (G_OBJECT (applet), "applet_info", info); - if (type != PANEL_OBJECT_BONOBO) + if (type != PANEL_OBJECT_APPLET) panel_lockdown_notify_add (G_CALLBACK (panel_applet_recreate_menu), info); - key = panel_gconf_full_key ((type == PANEL_OBJECT_BONOBO) ? + key = panel_gconf_full_key ((type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS, id, "locked"); panel_gconf_notify_add_while_alive (key, @@ -1243,7 +1242,7 @@ size_change (info, panel); back_change (info, panel); - if (type != PANEL_OBJECT_BONOBO) + if (type != PANEL_OBJECT_APPLET) gtk_widget_grab_focus (applet); else gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD); @@ -1276,7 +1275,7 @@ client = panel_gconf_get_client (); - key_type = (applet->type == PANEL_OBJECT_BONOBO) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; + key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; key = panel_gconf_full_key (key_type, applet->id, "position"); if (!gconf_client_key_is_writable (client, key, NULL)) @@ -1305,7 +1304,7 @@ client = panel_gconf_get_client (); - key_type = (applet->type == PANEL_OBJECT_BONOBO) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; + key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; key = panel_gconf_full_key (key_type, applet->id, "locked"); Index: gnome-panel/panel-addto.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-addto.c,v retrieving revision 1.39 diff -u -u -r1.39 panel-addto.c --- gnome-panel/panel-addto.c 19 Dec 2005 21:31:32 -0000 1.39 +++ gnome-panel/panel-addto.c 30 Dec 2005 18:06:55 -0000 @@ -25,7 +25,9 @@ #include #include -#include +#include + +#include #include "menu.h" @@ -158,16 +160,6 @@ TRUE } }; -static const char applet_requirements [] = - "has_all (repo_ids, ['IDL:Bonobo/Control:1.0'," - " 'IDL:GNOME/Vertigo/PanelAppletShell:1.0']) && " - "defined (panel:icon)"; - -static char *applet_sort_criteria [] = { - "name", - NULL - }; - enum { COLUMN_ICON, COLUMN_TEXT, @@ -359,72 +351,39 @@ static GSList * panel_addto_query_applets (GSList *list) { - Bonobo_ServerInfoList *applet_list; - CORBA_Environment env; - const char * const *langs; - GSList *langs_gslist; - int i; - - CORBA_exception_init (&env); - - applet_list = bonobo_activation_query (applet_requirements, - applet_sort_criteria, - &env); - if (BONOBO_EX (&env)) { - g_warning (_("query returned exception %s\n"), - BONOBO_EX_REPOID (&env)); - - CORBA_exception_free (&env); - CORBA_free (applet_list); - - return NULL; - } - - CORBA_exception_free (&env); + PanelAppletManager *manager; + GList *applet_list = NULL; + GList *l; - langs = g_get_language_names (); - - langs_gslist = NULL; - for (i = 0; langs[i]; i++) - langs_gslist = g_slist_prepend (langs_gslist, (char *) langs[i]); - - langs_gslist = g_slist_reverse (langs_gslist); - - for (i = 0; i < applet_list->_length; i++) { - Bonobo_ServerInfo *info; - const char *name, *description, *icon; + manager = panel_applet_manager_new (); + applet_list = panel_applet_manager_get_applets (manager); + + for (l = applet_list; l && l->data; l = g_list_next (l)) { + PanelAppletInfo *info; PanelAddtoItemInfo *applet; - info = &applet_list->_buffer[i]; - - name = bonobo_server_info_prop_lookup (info, - "name", - langs_gslist); - description = bonobo_server_info_prop_lookup (info, - "description", - langs_gslist); - icon = bonobo_server_info_prop_lookup (info, - "panel:icon", - NULL); + info = (PanelAppletInfo *) l->data; - if (!name || - panel_lockdown_is_applet_disabled (info->iid)) { + if (!info->id || + panel_lockdown_is_applet_disabled (info->id)) { continue; } applet = g_new0 (PanelAddtoItemInfo, 1); applet->type = PANEL_ADDTO_APPLET; - applet->name = g_strdup (name); - applet->description = g_strdup (description); - applet->icon = g_strdup (icon); - applet->iid = g_strdup (info->iid); + applet->name = g_strdup (info->name); + applet->description = g_strdup (info->comment); + applet->icon = g_strdup (info->icon); + applet->iid = g_strdup (info->id); applet->static_data = FALSE; list = g_slist_prepend (list, applet); + + panel_applet_info_free (info); } - g_slist_free (langs_gslist); - CORBA_free (applet_list); + g_list_free (applet_list); + g_object_unref (manager); return list; } Index: gnome-panel/panel-applet-frame.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-applet-frame.c,v retrieving revision 1.142 diff -u -u -r1.142 panel-applet-frame.c --- gnome-panel/panel-applet-frame.c 29 Dec 2005 18:08:59 -0000 1.142 +++ gnome-panel/panel-applet-frame.c 30 Dec 2005 18:06:55 -0000 @@ -26,11 +26,13 @@ #include #include -#include +#include #include #include #include +#include + #include "panel-applet-frame.h" #include "panel-profile.h" #include "panel-util.h" @@ -45,44 +47,20 @@ #undef PANEL_APPLET_FRAME_DEBUG -#define HANDLE_SIZE 10 - -#define PROPERTY_ORIENT "panel-applet-orient" -#define PROPERTY_SIZE "panel-applet-size" -#define PROPERTY_BACKGROUND "panel-applet-background" -#define PROPERTY_FLAGS "panel-applet-flags" -#define PROPERTY_SIZE_HINTS "panel-applet-size-hints" -#define PROPERTY_LOCKED_DOWN "panel-applet-locked-down" - - struct _PanelAppletFramePrivate { - GNOME_Vertigo_PanelAppletShell applet_shell; - CORBA_Object control; - Bonobo_PropertyBag property_bag; - BonoboUIComponent *ui_component; - - PanelWidget *panel; - AppletInfo *applet_info; - PanelOrientation orientation; - - gchar *iid; - gboolean moving_focus_out; - - GtkAllocation child_allocation; - GdkRectangle handle_rect; - - guint has_handle : 1; + PanelWidget *panel; + AppletInfo *applet_info; + gchar *iid; }; typedef struct { - PanelAppletFrame *frame; - gboolean locked; - int position; - gboolean exactpos; - char *id; + gboolean locked; + gint position; + gboolean exactpos; + gchar *id; } PanelAppletFrameActivating; -static GObjectClass *parent_class; +static PanelAppletContainerClass *parent_class; /* Keep in sync with panel-applet.h. Uggh. */ @@ -93,17 +71,17 @@ APPLET_HAS_HANDLE = 1 << 2 } PanelAppletFlags; -static void panel_applet_frame_cnx_broken (ORBitConnection *cnx, - PanelAppletFrame *frame); +#define HANDLE_SIZE 10 + +static void panel_applet_frame_cnx_broken (PanelAppletContainer *container); -static char *panel_applet_frame_construct_moniker (PanelAppletFrame *frame, - PanelWidget *panel, - const char *iid, - const char *id); - -static void panel_applet_frame_activated (Bonobo_Unknown object, - CORBA_Environment *ev, - gpointer *data); +static gboolean panel_applet_frame_activated (PanelAppletContainer *container, + GError *error, + gpointer user_data); + +static char *panel_applet_frame_get_background_string (PanelAppletFrame *frame, + PanelWidget *panel, + PanelBackgroundType type); void panel_applet_frame_sync_menu_state (PanelAppletFrame *frame) @@ -114,6 +92,7 @@ gboolean lockable; gboolean movable; gboolean removable; + GValue value = {0, }; panel_widget = PANEL_WIDGET (GTK_WIDGET (frame)->parent); @@ -123,127 +102,146 @@ locked = panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame)); - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/LockAppletToPanel", - "state", - locked ? "1" : "0", - NULL); - + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, locked); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Lock", "active", &value); + g_value_unset (&value); + /* First sensitivity */ - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/LockAppletToPanel", - "sensitive", - lockable ? "1" : "0", - NULL); - - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/RemoveAppletFromPanel", - "sensitive", - (locked && !lockable) ? "0" : (removable ? "1" : "0"), - NULL); - - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/MoveApplet", - "sensitive", - locked ? "0" : (movable ? "1" : "0"), - NULL); - + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, lockable); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Lock", "sensitive", &value); + g_value_unset (&value); + + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, (locked && !lockable) ? FALSE : removable); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Remove", "sensitive", &value); + g_value_unset (&value); + + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, locked ? FALSE : movable); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Move", "sensitive", &value); + g_value_unset (&value); + /* Second visibility */ locked_down = panel_lockdown_get_locked_down (); - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/LockAppletToPanel", - "hidden", - locked_down ? "1" : "0", - NULL); - - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/RemoveAppletFromPanel", - "hidden", - locked_down ? "1" : "0", - NULL); - - bonobo_ui_component_set_prop (frame->priv->ui_component, - "/commands/MoveApplet", - "hidden", - locked_down ? "1" : "0", - NULL); + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, !locked_down); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Lock", "visible", &value); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Remove", "visible", &value); + panel_applet_container_menu_set_property (PANEL_APPLET_CONTAINER (frame), + "Move", "visible", &value); + g_value_unset (&value); } static void -panel_applet_frame_set_flags_from_any (PanelAppletFrame *frame, - const CORBA_any *any) +panel_applet_frame_set_flags (PanelAppletFrame *frame, + guint flags) { gboolean major; gboolean minor; - int flags; - flags = BONOBO_ARG_GET_SHORT (any); - major = flags & APPLET_EXPAND_MAJOR; minor = flags & APPLET_EXPAND_MINOR; panel_widget_set_applet_expandable ( frame->priv->panel, GTK_WIDGET (frame), major, minor); - - frame->priv->has_handle = (flags & APPLET_HAS_HANDLE) != 0; + + g_object_set (G_OBJECT (frame), "has-handle", + (flags & APPLET_HAS_HANDLE) != 0, + NULL); } static void -panel_applet_frame_set_size_hints_from_any (PanelAppletFrame *frame, - const CORBA_any *any) +panel_applet_frame_set_size_hints (PanelAppletFrame *frame, + GValueArray *size_hints) { - CORBA_sequence_CORBA_long *seq; - int *size_hints; + int *hints; int extra_size; int i; + gboolean has_handle; - seq = any->_value; - - size_hints = g_new0 (int, seq->_length); - + if (g_value_get_int (g_value_array_get_nth (size_hints, 0)) == -1) + return; + + g_object_get (G_OBJECT (frame), "has-handle", &has_handle, NULL); + + hints = g_new0 (int, size_hints->n_values); + extra_size = 0; - if (frame->priv->has_handle) + if (has_handle) extra_size = HANDLE_SIZE + 1; - - for (i = 0; i < seq->_length; i++) - size_hints [i] = seq->_buffer [i] + extra_size; + + for (i = 0; i < size_hints->n_values; i++) { + hints[i] = g_value_get_int (g_value_array_get_nth (size_hints, i)) + extra_size; + } panel_widget_set_applet_size_hints (frame->priv->panel, GTK_WIDGET (frame), - size_hints, - seq->_length); + hints, + size_hints->n_values); +} + +static void +panel_applet_frame_flags_changed (PanelAppletFrame *frame, + const GValue *value, + gpointer user_data) +{ + guint flags; + + flags = g_value_get_uint (value); + panel_applet_frame_set_flags (frame, flags); +} + +static void +panel_applet_frame_size_hints_changed (PanelAppletFrame *frame, + const GValue *value, + gpointer user_data) +{ + GValueArray *size_hints; + + size_hints = g_value_get_boxed (value); + + panel_applet_frame_set_size_hints (frame, size_hints); } static void panel_applet_frame_init_properties (PanelAppletFrame *frame) { - CORBA_any *any; + guint flags; + GValueArray *size_hints; - any = bonobo_pbclient_get_value (frame->priv->property_bag, - PROPERTY_FLAGS, - BONOBO_ARG_SHORT, - NULL); - if (any) { - panel_applet_frame_set_flags_from_any (frame, any); - CORBA_free (any); - } - - any = bonobo_pbclient_get_value (frame->priv->property_bag, - PROPERTY_SIZE_HINTS, - TC_CORBA_sequence_CORBA_long, - NULL); - if (any) { - panel_applet_frame_set_size_hints_from_any (frame, any); - CORBA_free (any); - } + panel_applet_container_child_get (PANEL_APPLET_CONTAINER (frame), + "flags", &flags, + "size-hints", &size_hints, + NULL); + + panel_applet_frame_set_flags (frame, flags); + panel_applet_frame_set_size_hints (frame, size_hints); + + g_value_array_free (size_hints); + + panel_applet_container_child_notify_add (PANEL_APPLET_CONTAINER (frame), + "flags", + G_CALLBACK (panel_applet_frame_flags_changed), + NULL); + panel_applet_container_child_notify_add (PANEL_APPLET_CONTAINER (frame), + "size-hints", + G_CALLBACK (panel_applet_frame_size_hints_changed), + NULL); } static void -popup_handle_remove (BonoboUIComponent *uic, - PanelAppletFrame *frame, - const gchar *verbname) +popup_handle_remove (GtkAction *action, gpointer user_data) { + PanelAppletFrame *frame = PANEL_APPLET_FRAME (user_data); AppletInfo *info; info = frame->priv->applet_info; @@ -253,59 +251,48 @@ } static void -listener_popup_handle_lock (BonoboUIComponent *uic, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - gpointer data) +popup_handle_lock (GtkAction *action, gpointer user_data) { - PanelAppletFrame *frame; + PanelAppletFrame *frame = PANEL_APPLET_FRAME (user_data); AppletInfo *info; - gboolean s; - - g_assert (!strcmp (path, "LockAppletToPanel")); - - if (type != Bonobo_UIComponent_STATE_CHANGED) - return; - - if (!state) - return; + gboolean locked; - frame = (PanelAppletFrame *) data; info = frame->priv->applet_info; - s = (strcmp (state, "1") == 0); - + locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + if (panel_widget_get_applet_locked (PANEL_WIDGET (info->widget->parent), - info->widget) == s) + info->widget) == locked) return; - + panel_applet_toggle_locked (frame->priv->applet_info); panel_applet_frame_sync_menu_state (frame); } static void -popup_handle_move (BonoboUIComponent *uic, - PanelAppletFrame *frame, - const gchar *verbname) +popup_handle_move (GtkAction *action, gpointer user_data) { - GtkWidget *widget; - - g_return_if_fail (GTK_IS_WIDGET (frame)); + GtkWidget *widget = GTK_WIDGET (user_data); - widget = GTK_WIDGET (frame); - g_return_if_fail (PANEL_IS_WIDGET (widget->parent)); panel_widget_applet_drag_start ( PANEL_WIDGET (widget->parent), widget, PW_DRAG_OFF_CENTER, GDK_CURRENT_TIME); } -static BonoboUIVerb popup_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("RemoveAppletFromPanel", popup_handle_remove), - BONOBO_UI_UNSAFE_VERB ("MoveApplet", popup_handle_move), +static const GtkActionEntry popup_actions[] = { + { "Remove", GTK_STOCK_REMOVE, N_("_Remove From Panel"), + NULL, NULL, + G_CALLBACK (popup_handle_remove) }, + { "Move", NULL, N_("_Move"), + NULL, NULL, + G_CALLBACK (popup_handle_move) }, +}; - BONOBO_UI_VERB_END +static const GtkToggleActionEntry popup_toggle_actions[] = { + { "Lock", NULL, N_("_Lock To Panel"), + NULL, NULL, + G_CALLBACK (popup_handle_lock), FALSE }, }; static void @@ -316,10 +303,11 @@ gboolean exactpos, const char *id) { - PanelAppletFrame *frame; - CORBA_Environment ev; - char *moniker; PanelAppletFrameActivating *frame_act; + PanelAppletFrame *frame; + gchar *prefs_key; + gchar *background; + guint orient, size; g_return_if_fail (iid != NULL); g_return_if_fail (panel != NULL); @@ -333,21 +321,29 @@ frame->priv->iid = g_strdup (iid); frame_act = g_new (PanelAppletFrameActivating, 1); - frame_act->frame = frame; frame_act->locked = locked; frame_act->position = position; frame_act->exactpos = exactpos; frame_act->id = g_strdup (id); - moniker = panel_applet_frame_construct_moniker (frame, panel, iid, id); - - CORBA_exception_init (&ev); - - bonobo_get_object_async (moniker, "IDL:Bonobo/Control:1.0", &ev, - (BonoboMonikerAsyncFn) panel_applet_frame_activated, - frame_act); - - g_free (moniker); + prefs_key = g_strdup_printf ("/apps/panel/applets/%s/prefs", id); + background = panel_applet_frame_get_background_string (frame, + panel, + panel->background.type); + orient = panel_widget_get_applet_orientation (panel); + size = panel->sz; + + panel_applet_container_add_with_properties (PANEL_APPLET_CONTAINER (frame), iid, + (PanelAppletActivateCb)panel_applet_frame_activated, + frame_act, + "prefs-key", prefs_key, + "background", background, + "orient", orient, + "size", size, + "locked-down", locked, + NULL); + g_free (prefs_key); + g_free (background); } void @@ -357,17 +353,23 @@ const char *id) { const char *key; - char *applet_iid; + char *applet_id; g_return_if_fail (panel_widget != NULL); g_return_if_fail (id != NULL); - key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid"); - applet_iid = gconf_client_get_string (panel_gconf_get_client (), key, NULL); + key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_id"); + applet_id = gconf_client_get_string (panel_gconf_get_client (), key, NULL); - panel_applet_frame_load (applet_iid, panel_widget, locked, position, TRUE, id); + if (!applet_id) { + /* Compatibility */ + key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid"); + applet_id = gconf_client_get_string (panel_gconf_get_client (), key, NULL); + } + + panel_applet_frame_load (applet_id, panel_widget, locked, position, TRUE, id); - g_free (applet_iid); + g_free (applet_id); } void @@ -383,9 +385,9 @@ client = panel_gconf_get_client (); - id = panel_profile_prepare_object (PANEL_OBJECT_BONOBO, toplevel, position, FALSE); + id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position, FALSE); - key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid"); + key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_id"); gconf_client_set_string (client, key, iid, NULL); panel_profile_add_to_list (PANEL_GCONF_APPLETS, id); @@ -397,57 +399,54 @@ panel_applet_frame_change_orientation (PanelAppletFrame *frame, PanelOrientation orientation) { - CORBA_unsigned_short orient = 0; - - if (orientation == frame->priv->orientation) - return; + GtkOrientation orient; + gboolean changed = TRUE; - frame->priv->orientation = orientation; + g_object_get (G_OBJECT (frame), "orient", &orient, NULL); switch (orientation) { case PANEL_ORIENTATION_TOP: - orient = GNOME_Vertigo_PANEL_ORIENT_DOWN; - break; case PANEL_ORIENTATION_BOTTOM: - orient = GNOME_Vertigo_PANEL_ORIENT_UP; + if (orient == GTK_ORIENTATION_HORIZONTAL) + changed = FALSE; + orient = GTK_ORIENTATION_HORIZONTAL; break; case PANEL_ORIENTATION_LEFT: - orient = GNOME_Vertigo_PANEL_ORIENT_RIGHT; - break; case PANEL_ORIENTATION_RIGHT: - orient = GNOME_Vertigo_PANEL_ORIENT_LEFT; + if (orient == GTK_ORIENTATION_VERTICAL) + changed = FALSE; + orient = GTK_ORIENTATION_VERTICAL; break; default: g_assert_not_reached (); break; } - bonobo_pbclient_set_short (frame->priv->property_bag, - PROPERTY_ORIENT, - orient, - NULL); - + if (changed) + g_object_set (G_OBJECT (frame), "orient", orient, NULL); + + panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame), + "orient", orientation, NULL); + gtk_widget_queue_resize (GTK_WIDGET (frame)); } void panel_applet_frame_change_size (PanelAppletFrame *frame, - PanelSize size) + gint size) { /* Normalise the size to the constants defined in * the IDL. */ - size = size <= PANEL_SIZE_XX_SMALL ? PANEL_SIZE_XX_SMALL : +/* size = size <= PANEL_SIZE_XX_SMALL ? PANEL_SIZE_XX_SMALL : size <= PANEL_SIZE_X_SMALL ? PANEL_SIZE_X_SMALL : size <= PANEL_SIZE_SMALL ? PANEL_SIZE_SMALL : size <= PANEL_SIZE_MEDIUM ? PANEL_SIZE_MEDIUM : size <= PANEL_SIZE_LARGE ? PANEL_SIZE_LARGE : - size <= PANEL_SIZE_X_LARGE ? PANEL_SIZE_X_LARGE : PANEL_SIZE_XX_LARGE; - - bonobo_pbclient_set_short (frame->priv->property_bag, - PROPERTY_SIZE, - size, - NULL); + size <= PANEL_SIZE_X_LARGE ? PANEL_SIZE_X_LARGE : PANEL_SIZE_XX_LARGE;*/ + + panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame), + "size", size, NULL); } static char * @@ -455,23 +454,30 @@ PanelWidget *panel, PanelBackgroundType type) { - int x; - int y; + int x; + int y; + gboolean has_handle; + PanelOrientation orient; + GdkRectangle handle_rect; x = GTK_WIDGET (frame)->allocation.x; y = GTK_WIDGET (frame)->allocation.y; - if (frame->priv->has_handle) { - switch (frame->priv->orientation) { - case PANEL_ORIENTATION_TOP: - case PANEL_ORIENTATION_BOTTOM: + g_object_get (G_OBJECT (frame), + "has-handle", &has_handle, + "handle-rect", &handle_rect, + "orient", &orient, + NULL); + + if (has_handle) { + switch (orient) { + case GTK_ORIENTATION_HORIZONTAL: if (gtk_widget_get_direction (GTK_WIDGET (frame)) != GTK_TEXT_DIR_RTL) - x += frame->priv->handle_rect.width; + x += handle_rect.width; break; - case PANEL_ORIENTATION_LEFT: - case PANEL_ORIENTATION_RIGHT: - y += frame->priv->handle_rect.height; + case GTK_ORIENTATION_VERTICAL: + y += handle_rect.height; break; default: g_assert_not_reached (); @@ -486,12 +492,17 @@ panel_applet_frame_change_background (PanelAppletFrame *frame, PanelBackgroundType type) { - char *bg_str; + char *bg_str; + gboolean has_handle; g_return_if_fail (PANEL_IS_APPLET_FRAME (frame)); g_return_if_fail (PANEL_IS_WIDGET (GTK_WIDGET (frame)->parent)); - if (frame->priv->has_handle) { + g_object_get (G_OBJECT (frame), + "has-handle", &has_handle, + NULL); + + if (has_handle) { PanelBackground *background; background = &PANEL_WIDGET (GTK_WIDGET (frame)->parent)->background; @@ -502,101 +513,26 @@ bg_str = panel_applet_frame_get_background_string ( frame, PANEL_WIDGET (GTK_WIDGET (frame)->parent), type); - if (bg_str != NULL) { - bonobo_pbclient_set_string (frame->priv->property_bag, - PROPERTY_BACKGROUND, - bg_str, NULL); - + if (bg_str) { + panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame), + "background", bg_str, NULL); g_free (bg_str); } } static void -panel_applet_frame_finalize (GObject *object) +panel_applet_frame_dispose (GObject *object) { PanelAppletFrame *frame = PANEL_APPLET_FRAME (object); panel_lockdown_notify_remove (G_CALLBACK (panel_applet_frame_sync_menu_state), frame); - if (frame->priv->property_bag) - bonobo_object_release_unref ( - frame->priv->property_bag, NULL); - - if (frame->priv->applet_shell) - bonobo_object_release_unref ( - frame->priv->applet_shell, NULL); - - if (frame->priv->ui_component) - bonobo_object_unref ( - BONOBO_OBJECT (frame->priv->ui_component)); - - if (frame->priv->control) { - ORBit_small_unlisten_for_broken (frame->priv->control, - G_CALLBACK (panel_applet_frame_cnx_broken)); - CORBA_Object_release (frame->priv->control, NULL); - frame->priv->control = CORBA_OBJECT_NIL; - } - g_free (frame->priv->iid); frame->priv->iid = NULL; - parent_class->finalize (object); -} - -static void -panel_applet_frame_paint (GtkWidget *widget, - GdkRectangle *area) -{ - PanelAppletFrame *frame; - - frame = PANEL_APPLET_FRAME (widget); - - if (!frame->priv->has_handle) - return; - - if (GTK_WIDGET_DRAWABLE (widget)) { - GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL; - - switch (frame->priv->orientation) { - case PANEL_ORIENTATION_TOP: - case PANEL_ORIENTATION_BOTTOM: - orientation = GTK_ORIENTATION_HORIZONTAL; - break; - case PANEL_ORIENTATION_LEFT: - case PANEL_ORIENTATION_RIGHT: - orientation = GTK_ORIENTATION_VERTICAL; - break; - default: - g_assert_not_reached (); - break; - } - - gtk_paint_handle ( - widget->style, widget->window, - GTK_WIDGET_STATE (widget), - GTK_SHADOW_OUT, - area, widget, "handlebox", - frame->priv->handle_rect.x, - frame->priv->handle_rect.y, - frame->priv->handle_rect.width, - frame->priv->handle_rect.height, - orientation); - } -} - -static gboolean -panel_applet_frame_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - if (GTK_WIDGET_DRAWABLE (widget)) { - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - - panel_applet_frame_paint (widget, &event->area); - - } - - return FALSE; + if (G_OBJECT_CLASS (parent_class)->dispose) + (* G_OBJECT_CLASS (parent_class)->dispose) (object); } static void @@ -622,56 +558,10 @@ } static void -panel_applet_frame_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - PanelAppletFrame *frame; - GtkBin *bin; - GtkRequisition child_requisition; - - frame = PANEL_APPLET_FRAME (widget); - bin = GTK_BIN (widget); - - if (!frame->priv->has_handle) { - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - return; - } - - requisition->width = 0; - requisition->height = 0; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &child_requisition); - - requisition->width = child_requisition.width; - requisition->height = child_requisition.height; - } - - requisition->width += GTK_CONTAINER (widget)->border_width; - requisition->height += GTK_CONTAINER (widget)->border_width; - - switch (frame->priv->orientation) { - case PANEL_ORIENTATION_TOP: - case PANEL_ORIENTATION_BOTTOM: - requisition->width += HANDLE_SIZE; - break; - case PANEL_ORIENTATION_LEFT: - case PANEL_ORIENTATION_RIGHT: - requisition->height += HANDLE_SIZE; - break; - default: - g_assert_not_reached (); - break; - } -} - -static void panel_applet_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { PanelAppletFrame *frame; - GtkBin *bin; - GtkAllocation new_allocation; GtkAllocation old_allocation; old_allocation.x = widget->allocation.x; @@ -680,82 +570,9 @@ old_allocation.height = widget->allocation.height; frame = PANEL_APPLET_FRAME (widget); - bin = GTK_BIN (widget); - - if (!frame->priv->has_handle) { - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, - allocation); - panel_applet_frame_update_background_size (frame, - &old_allocation, - allocation); - return; - } - - widget->allocation = *allocation; - - frame->priv->handle_rect.x = 0; - frame->priv->handle_rect.y = 0; - - switch (frame->priv->orientation) { - case PANEL_ORIENTATION_TOP: - case PANEL_ORIENTATION_BOTTOM: - frame->priv->handle_rect.width = HANDLE_SIZE; - frame->priv->handle_rect.height = allocation->height; - - if (gtk_widget_get_direction (GTK_WIDGET (frame)) != - GTK_TEXT_DIR_RTL) { - frame->priv->handle_rect.x = 0; - new_allocation.x = HANDLE_SIZE; - } else { - frame->priv->handle_rect.x = allocation->width - HANDLE_SIZE; - new_allocation.x = 0; - } - - new_allocation.y = 0; - new_allocation.width = allocation->width - HANDLE_SIZE; - new_allocation.height = allocation->height; - break; - case PANEL_ORIENTATION_LEFT: - case PANEL_ORIENTATION_RIGHT: - frame->priv->handle_rect.width = allocation->width; - frame->priv->handle_rect.height = HANDLE_SIZE; - - new_allocation.x = 0; - new_allocation.y = HANDLE_SIZE; - new_allocation.width = allocation->width; - new_allocation.height = allocation->height - HANDLE_SIZE; - break; - default: - g_assert_not_reached (); - break; - } - - new_allocation.width = MAX (1, new_allocation.width); - new_allocation.height = MAX (1, new_allocation.height); - - /* If the child allocation changed, that means that the frame is drawn - * in a new place, so we must redraw the entire widget. - */ - if (GTK_WIDGET_MAPPED (widget) && - (new_allocation.x != frame->priv->child_allocation.x || - new_allocation.y != frame->priv->child_allocation.y || - new_allocation.width != frame->priv->child_allocation.width || - new_allocation.height != frame->priv->child_allocation.height)) - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); - - if (GTK_WIDGET_REALIZED (widget)) { - gdk_window_move_resize (widget->window, - allocation->x + GTK_CONTAINER (widget)->border_width, - allocation->y + GTK_CONTAINER (widget)->border_width, - MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0), - MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0)); - } - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - gtk_widget_size_allocate (bin->child, &new_allocation); - - frame->priv->child_allocation = new_allocation; - + + GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, + allocation); panel_applet_frame_update_background_size (frame, &old_allocation, allocation); @@ -780,10 +597,17 @@ { PanelAppletFrame *frame; gboolean handled = FALSE; + gboolean has_handle; + GdkRectangle handle_rect; frame = PANEL_APPLET_FRAME (widget); - if (!frame->priv->has_handle) + g_object_get (G_OBJECT (frame), + "has-handle", &has_handle, + "handle-rect", &handle_rect, + NULL); + + if (!has_handle) return handled; if (event->window != widget->window) @@ -792,7 +616,7 @@ switch (event->button) { case 1: case 2: - if (button_event_in_rect (event, &frame->priv->handle_rect)) { + if (button_event_in_rect (event, &handle_rect)) { if (event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) { panel_widget_applet_drag_start ( @@ -805,28 +629,19 @@ } } break; - case 3: + case 3: if (event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) { - CORBA_Environment env; - - CORBA_exception_init (&env); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - - GNOME_Vertigo_PanelAppletShell_popup_menu ( - frame->priv->applet_shell, - event->button, - event->time, &env); - if (BONOBO_EX (&env)) - g_warning (_("Exception from popup_menu '%s'\n"), env._id); - - CORBA_exception_free (&env); + panel_applet_container_menu_popup ( + PANEL_APPLET_CONTAINER (frame), + event->button, + event->time); handled = TRUE; - - } else if (event->type == GDK_BUTTON_RELEASE) + } else if (event->type == GDK_BUTTON_RELEASE) { handled = TRUE; + } break; default: break; @@ -880,67 +695,47 @@ panel_profile_delete_object (info); } - g_object_unref (frame); + gtk_widget_destroy (GTK_WIDGET (frame)); gtk_widget_destroy (dialog); } static char * panel_applet_frame_get_name (char *iid) { - Bonobo_ServerInfoList *list; - char *query; - char *retval = NULL; - - query = g_strdup_printf ("iid == '%s'", iid); - - list = bonobo_activation_query (query, NULL, NULL); - if (list && list->_length > 0 && list->_buffer) { - Bonobo_ServerInfo *info = &list->_buffer [0]; - const char * const *langs; - GSList *langs_gslist; - int i; - - langs = g_get_language_names (); - - langs_gslist = NULL; - for (i = 0; langs[i]; i++) - langs_gslist = g_slist_prepend (langs_gslist, - (char *) langs[i]); - - langs_gslist = g_slist_reverse (langs_gslist); - - retval = g_strdup (bonobo_server_info_prop_lookup ( - info, "name", langs_gslist)); - - g_slist_free (langs_gslist); + PanelAppletManager *manager; + PanelAppletInfo *info; + char *retval = NULL; + + manager = panel_applet_manager_new (); + info = panel_applet_manager_get_applet_info (manager, iid); + if (info) { + retval = g_strdup (info->name); + panel_applet_info_free (info); } - - g_free (query); - CORBA_free (list); - + g_object_unref (manager); + return retval; } static void -panel_applet_frame_cnx_broken (ORBitConnection *cnx, - PanelAppletFrame *frame) +panel_applet_frame_cnx_broken (PanelAppletContainer *container) { - GtkWidget *dialog; - GdkScreen *screen; - char *applet_name = NULL; - char *dialog_txt; - - g_return_if_fail (PANEL_IS_APPLET_FRAME (frame)); + PanelAppletFrame *frame; + GtkWidget *dialog; + GdkScreen *screen; + char *applet_name = NULL; + char *dialog_txt; + frame = PANEL_APPLET_FRAME (container); + screen = gtk_widget_get_screen (GTK_WIDGET (frame)); - if (frame->priv->iid) - applet_name = panel_applet_frame_get_name (frame->priv->iid); + applet_name = panel_applet_frame_get_name (frame->priv->iid); if (applet_name) dialog_txt = g_strdup_printf (_("\"%s\" has quit unexpectedly"), applet_name); else - dialog_txt = g_strdup (_("Panel object has quit unexpectedly")); + dialog_txt = g_strdup (_("Panel object has quit unexpectedly")); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, @@ -995,14 +790,21 @@ const char *id) { GtkWidget *dialog; + char *applet_name; char *problem_txt; gboolean locked_down; locked_down = panel_lockdown_get_locked_down (); + applet_name = panel_applet_frame_get_name (frame->priv->iid); + + if (!applet_name) + applet_name = g_strdup (frame->priv->iid); + problem_txt = g_strdup_printf (_("The panel encountered a problem " "while loading \"%s\"."), - frame->priv->iid); + applet_name); + g_free (applet_name); dialog = gtk_message_dialog_new (NULL, 0, locked_down ? GTK_MESSAGE_INFO : GTK_MESSAGE_QUESTION, @@ -1035,9 +837,6 @@ gtk_widget_show_all (dialog); - g_free (frame->priv->iid); - frame->priv->iid = NULL; - gtk_widget_destroy (GTK_WIDGET (frame)); } @@ -1047,17 +846,19 @@ { GObjectClass *gobject_class = (GObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; + PanelAppletContainerClass *container_class = + (PanelAppletContainerClass *) container_class; parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = panel_applet_frame_finalize; + gobject_class->dispose = panel_applet_frame_dispose; - widget_class->expose_event = panel_applet_frame_expose; - widget_class->size_request = panel_applet_frame_size_request; widget_class->size_allocate = panel_applet_frame_size_allocate; widget_class->button_press_event = panel_applet_frame_button_changed; widget_class->button_release_event = panel_applet_frame_button_changed; + container_class->applet_broken = panel_applet_frame_cnx_broken; + g_type_class_add_private (klass, sizeof (PanelAppletFramePrivate)); } @@ -1067,14 +868,8 @@ { frame->priv = PANEL_APPLET_FRAME_GET_PRIVATE (frame); - frame->priv->applet_shell = CORBA_OBJECT_NIL; - frame->priv->property_bag = CORBA_OBJECT_NIL; - frame->priv->ui_component = NULL; - frame->priv->panel = NULL; - frame->priv->orientation = PANEL_ORIENTATION_TOP; - frame->priv->applet_info = NULL; - frame->priv->moving_focus_out = FALSE; - frame->priv->has_handle = FALSE; + frame->priv->panel = NULL; + frame->priv->applet_info = NULL; } GType @@ -1096,7 +891,7 @@ NULL }; - type = g_type_register_static (GTK_TYPE_EVENT_BOX, + type = g_type_register_static (PANEL_TYPE_APPLET_CONTAINER, "PanelAppletFrame", &info, 0); } @@ -1104,273 +899,47 @@ return type; } -static GNOME_Vertigo_PanelAppletShell -panel_applet_frame_get_applet_shell (Bonobo_Control control) -{ - CORBA_Environment env; - GNOME_Vertigo_PanelAppletShell retval; - - CORBA_exception_init (&env); - - retval = Bonobo_Unknown_queryInterface (control, - "IDL:GNOME/Vertigo/PanelAppletShell:1.0", - &env); - if (BONOBO_EX (&env)) { - g_warning (_("Unable to obtain AppletShell interface from control\n")); - - retval = CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&env); - - return retval; -} - -static G_CONST_RETURN char * -panel_applet_frame_get_orient_string (PanelAppletFrame *frame, - PanelWidget *panel) -{ - PanelOrientation orientation; - const char *retval = NULL; - - orientation = panel_widget_get_applet_orientation (panel); - - switch (orientation) { - case PANEL_ORIENTATION_TOP: - retval = "down"; - break; - case PANEL_ORIENTATION_BOTTOM: - retval = "up"; - break; - case PANEL_ORIENTATION_LEFT: - retval = "right"; - break; - case PANEL_ORIENTATION_RIGHT: - retval = "left"; - break; - default: - g_assert_not_reached (); - break; - } - - return retval; -} - -static G_CONST_RETURN char * -panel_applet_frame_get_size_string (PanelAppletFrame *frame, - PanelWidget *panel) -{ - const char *retval = NULL; - - if (panel->sz <= PANEL_SIZE_XX_SMALL) - retval = "xx-small"; - else if (panel->sz <= PANEL_SIZE_X_SMALL) - retval = "x-small"; - else if (panel->sz <= PANEL_SIZE_SMALL) - retval = "small"; - else if (panel->sz <= PANEL_SIZE_MEDIUM) - retval = "medium"; - else if (panel->sz <= PANEL_SIZE_LARGE) - retval = "large"; - else if (panel->sz <= PANEL_SIZE_X_LARGE) - retval = "x-large"; - else - retval = "xx-large"; - - return retval; -} - -static char * -panel_applet_frame_construct_moniker (PanelAppletFrame *frame, - PanelWidget *panel, - const char *iid, - const char *id) -{ - char *retval; - char *bg_str; - gboolean locked_down; - - bg_str = panel_applet_frame_get_background_string ( - frame, panel, panel->background.type); - - if (bg_str == NULL) - bg_str = g_strdup (""); - - locked_down = panel_lockdown_get_locked_down (); - - retval = g_strdup_printf ( - "%s!prefs_key=/apps/panel/applets/%s/prefs;" - "background=%s;orient=%s;size=%s;locked_down=%s", - iid, id, bg_str, - panel_applet_frame_get_orient_string (frame, panel), - panel_applet_frame_get_size_string (frame, panel), - locked_down ? "true" : "false"); - - g_free (bg_str); - - return retval; -} - -static void -panel_applet_frame_event_listener (BonoboListener *listener, - const char *event, - const CORBA_any *any, - CORBA_Environment *ev, - PanelAppletFrame *frame) -{ - if (!strcmp (event, "Bonobo/Property:change:" PROPERTY_FLAGS)) - panel_applet_frame_set_flags_from_any (frame, any); - - else if (!strcmp (event, "Bonobo/Property:change:" PROPERTY_SIZE_HINTS)) - panel_applet_frame_set_size_hints_from_any (frame, any); -} - -static void -panel_applet_frame_activated (Bonobo_Unknown object, - CORBA_Environment *ev, - gpointer *data) +static gboolean +panel_applet_frame_activated (PanelAppletContainer *container, + GError *error, + gpointer user_data) { PanelAppletFrameActivating *frame_act; - PanelAppletFrame *frame; - GtkWidget *widget; - BonoboControlFrame *control_frame; - Bonobo_Control control; - CORBA_Environment corba_ev; - AppletInfo *info; - char *error; - - frame_act = (PanelAppletFrameActivating *) data; - frame = frame_act->frame; - - /* according to the source of bonobo control == NULL && no - exception can happen, so handle it */ - if (BONOBO_EX (ev) || object == CORBA_OBJECT_NIL) { - error = bonobo_exception_get_text (ev); - g_warning (G_STRLOC ": failed to load applet %s:\n%s", - frame->priv->iid, error); - panel_applet_frame_loading_failed (frame, frame_act->id); - g_free (frame_act->id); - g_free (frame_act); - g_free (error); - return; - } - - frame->priv->control = CORBA_Object_duplicate (object, NULL); + PanelAppletFrame *frame; + AppletInfo *info; - widget = bonobo_widget_new_control_from_objref (object, - CORBA_OBJECT_NIL); + frame_act = (PanelAppletFrameActivating *) user_data; + frame = PANEL_APPLET_FRAME (container); - bonobo_object_release_unref (object, NULL); + if (error) { + g_warning (error->message); + g_clear_error (&error); - if (!widget) { - g_warning (G_STRLOC ": failed to load applet %s", - frame->priv->iid); panel_applet_frame_loading_failed (frame, frame_act->id); - g_free (frame_act->id); - g_free (frame_act); - return; - } - control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (widget)); - if (control_frame == NULL) { - g_warning (G_STRLOC ": failed to load applet %s " - "(can't get control frame)", frame->priv->iid); - panel_applet_frame_loading_failed (frame, frame_act->id); - gtk_object_sink (GTK_OBJECT (widget)); g_free (frame_act->id); g_free (frame_act); - return; - } - frame->priv->property_bag = - bonobo_control_frame_get_control_property_bag (control_frame, - &corba_ev); - if (frame->priv->property_bag == NULL || BONOBO_EX (&corba_ev)) { - error = bonobo_exception_get_text (&corba_ev); - CORBA_exception_free (&corba_ev); - g_warning (G_STRLOC ": failed to load applet %s " - "(can't get property bag):\n%s", - frame->priv->iid, error); - panel_applet_frame_loading_failed (frame, frame_act->id); - gtk_object_sink (GTK_OBJECT (widget)); - g_free (frame_act->id); - g_free (frame_act); - g_free (error); - return; + return FALSE; } - bonobo_event_source_client_add_listener (frame->priv->property_bag, - (BonoboListenerCallbackFn) panel_applet_frame_event_listener, - "Bonobo/Property:change:panel-applet", - NULL, + panel_applet_container_menu_add_actions (PANEL_APPLET_CONTAINER (frame), + popup_actions, + G_N_ELEMENTS (popup_actions), frame); - - frame->priv->ui_component = - bonobo_control_frame_get_popup_component (control_frame, - &corba_ev); - if (frame->priv->ui_component == NULL || BONOBO_EX (&corba_ev)) { - error = bonobo_exception_get_text (&corba_ev); - CORBA_exception_free (&corba_ev); - g_warning (G_STRLOC ": failed to load applet %s " - "(can't get popup component):\n%s", - frame->priv->iid, error); - panel_applet_frame_loading_failed (frame, frame_act->id); - gtk_object_sink (GTK_OBJECT (widget)); - g_free (frame_act->id); - g_free (frame_act); - g_free (error); - return; - } - - bonobo_ui_util_set_ui (frame->priv->ui_component, DATADIR, - "GNOME_Panel_Popup.xml", "panel", NULL); - - bonobo_ui_component_add_listener (frame->priv->ui_component, - "LockAppletToPanel", - listener_popup_handle_lock, - frame); - - bonobo_ui_component_add_verb_list_with_data ( - frame->priv->ui_component, popup_verbs, frame); - - control = bonobo_control_frame_get_control (control_frame); - if (!control) { - CORBA_exception_free (&corba_ev); - g_warning (G_STRLOC ": failed to load applet %s " - "(can't get control)", frame->priv->iid); - panel_applet_frame_loading_failed (frame, frame_act->id); - gtk_object_sink (GTK_OBJECT (widget)); - g_free (frame_act->id); - g_free (frame_act); - return; - } - - frame->priv->applet_shell = panel_applet_frame_get_applet_shell (control); - if (frame->priv->applet_shell == CORBA_OBJECT_NIL) { - CORBA_exception_free (&corba_ev); - g_warning (G_STRLOC ": failed to load applet %s " - "(can't get applet shell)", frame->priv->iid); - panel_applet_frame_loading_failed (frame, frame_act->id); - gtk_object_sink (GTK_OBJECT (widget)); - g_free (frame_act->id); - g_free (frame_act); - return; - } - - CORBA_exception_free (&corba_ev); - - ORBit_small_listen_for_broken (object, - G_CALLBACK (panel_applet_frame_cnx_broken), - frame); - - gtk_container_add (GTK_CONTAINER (frame), widget); - - gtk_widget_show_all (GTK_WIDGET (frame)); + panel_applet_container_menu_add_toggle_actions (PANEL_APPLET_CONTAINER (frame), + popup_toggle_actions, + G_N_ELEMENTS (popup_toggle_actions), + frame); + panel_applet_container_menu_add_ui_from_file (PANEL_APPLET_CONTAINER (frame), + NULL, + "GNOME_Panel_Popup.xml", + NULL); info = panel_applet_register (GTK_WIDGET (frame), GTK_WIDGET (frame), NULL, frame->priv->panel, frame_act->locked, frame_act->position, - frame_act->exactpos, PANEL_OBJECT_BONOBO, + frame_act->exactpos, PANEL_OBJECT_APPLET, frame_act->id); frame->priv->applet_info = info; @@ -1385,6 +954,8 @@ g_free (frame_act->id); g_free (frame_act); + + return TRUE; } void Index: gnome-panel/panel-applet-frame.h =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-applet-frame.h,v retrieving revision 1.35 diff -u -u -r1.35 panel-applet-frame.h --- gnome-panel/panel-applet-frame.h 2 Jan 2005 12:57:44 -0000 1.35 +++ gnome-panel/panel-applet-frame.h 30 Dec 2005 18:06:55 -0000 @@ -25,7 +25,7 @@ #ifndef __PANEL_APPLET_FRAME_H__ #define __PANEL_APPLET_FRAME_H__ -#include +#include #include "panel-widget.h" #include "applet.h" @@ -44,13 +44,13 @@ typedef struct _PanelAppletFramePrivate PanelAppletFramePrivate; struct _PanelAppletFrame{ - GtkEventBox event_box; + PanelAppletContainer parent; PanelAppletFramePrivate *priv; }; struct _PanelAppletFrameClass { - GtkEventBoxClass event_box_class; + PanelAppletContainerClass parent_class; }; GType panel_applet_frame_get_type (void) G_GNUC_CONST; @@ -65,7 +65,7 @@ PanelOrientation orientation); void panel_applet_frame_change_size (PanelAppletFrame *frame, - PanelSize size); + gint size); void panel_applet_frame_change_background (PanelAppletFrame *frame, PanelBackgroundType type); Index: gnome-panel/panel-compatibility.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-compatibility.c,v retrieving revision 1.17 diff -u -u -r1.17 panel-compatibility.c --- gnome-panel/panel-compatibility.c 22 Sep 2005 12:40:38 -0000 1.17 +++ gnome-panel/panel-compatibility.c 30 Dec 2005 18:06:55 -0000 @@ -34,10 +34,10 @@ #include "panel-util.h" typedef enum { - PANEL_ORIENT_UP = GNOME_Vertigo_PANEL_ORIENT_UP, - PANEL_ORIENT_DOWN = GNOME_Vertigo_PANEL_ORIENT_DOWN, - PANEL_ORIENT_LEFT = GNOME_Vertigo_PANEL_ORIENT_LEFT, - PANEL_ORIENT_RIGHT = GNOME_Vertigo_PANEL_ORIENT_RIGHT + PANEL_ORIENT_UP, + PANEL_ORIENT_DOWN, + PANEL_ORIENT_LEFT, + PANEL_ORIENT_RIGHT } PanelOrient; static GConfEnumStringPair panel_orient_map [] = { @@ -524,7 +524,7 @@ g_free (id); /* window menu on far left corner */ - id = panel_profile_prepare_object_with_id (PANEL_OBJECT_BONOBO, toplevel_id, 0, TRUE); + id = panel_profile_prepare_object_with_id (PANEL_OBJECT_APPLET, toplevel_id, 0, TRUE); key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid"); gconf_client_set_string (client, key, "OAFIID:GNOME_WindowMenuApplet", NULL); Index: gnome-panel/panel-enums.h =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-enums.h,v retrieving revision 1.8 diff -u -u -r1.8 panel-enums.h --- gnome-panel/panel-enums.h 14 Jan 2005 21:50:08 -0000 1.8 +++ gnome-panel/panel-enums.h 30 Dec 2005 18:06:55 -0000 @@ -78,7 +78,7 @@ PANEL_OBJECT_DRAWER, PANEL_OBJECT_MENU, PANEL_OBJECT_LAUNCHER, - PANEL_OBJECT_BONOBO, + PANEL_OBJECT_APPLET, PANEL_OBJECT_ACTION, PANEL_OBJECT_MENU_BAR, /* The following two are for backwards compatibility with 2.0.x */ Index: gnome-panel/panel-lockdown.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-lockdown.c,v retrieving revision 1.3 diff -u -u -r1.3 panel-lockdown.c --- gnome-panel/panel-lockdown.c 10 Jan 2005 16:41:00 -0000 1.3 +++ gnome-panel/panel-lockdown.c 30 Dec 2005 18:06:55 -0000 @@ -433,7 +433,8 @@ callback_func, user_data); - g_assert (closure != NULL); + if (!closure) + return; panel_lockdown.closures = g_slist_remove (panel_lockdown.closures, closure); Index: gnome-panel/panel-object.schemas.in =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-object.schemas.in,v retrieving revision 1.7 diff -u -u -r1.7 panel-object.schemas.in --- gnome-panel/panel-object.schemas.in 28 Jan 2005 23:41:09 -0000 1.7 +++ gnome-panel/panel-object.schemas.in 30 Dec 2005 18:06:55 -0000 @@ -15,7 +15,7 @@ The type of this panel object. Possible values are "drawer-object", "menu-object", "launcher-object", - "bonobo-applet", "action-applet" and "menu-bar". + "gnome-applet", "action-applet" and "menu-bar". @@ -80,16 +80,16 @@ - /schemas/apps/panel/objects/bonobo_iid + /schemas/apps/panel/objects/applet_id panel string - Applet Bonobo IID + Applet Identifier - The Bonobo implementation ID of the applet - e.g. - "OAFIID:GNOME_ClockApplet". This key is only - relevant if the object_type key is "bonobo-applet". + The identifier of the applet - e.g. + "Clock". This key is only + relevant if the object_type key is "gnome-applet". Index: gnome-panel/panel-profile.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-profile.c,v retrieving revision 1.50 diff -u -u -r1.50 panel-profile.c --- gnome-panel/panel-profile.c 22 Oct 2005 07:06:03 -0000 1.50 +++ gnome-panel/panel-profile.c 30 Dec 2005 18:06:56 -0000 @@ -90,12 +90,12 @@ }; static GConfEnumStringPair panel_object_type_map [] = { - { PANEL_OBJECT_DRAWER, "drawer-object" }, - { PANEL_OBJECT_MENU, "menu-object" }, - { PANEL_OBJECT_LAUNCHER, "launcher-object" }, - { PANEL_OBJECT_BONOBO, "bonobo-applet" }, - { PANEL_OBJECT_ACTION, "action-applet" }, - { PANEL_OBJECT_MENU_BAR, "menu-bar" }, + { PANEL_OBJECT_DRAWER, "drawer-object" }, + { PANEL_OBJECT_MENU, "menu-object" }, + { PANEL_OBJECT_LAUNCHER, "launcher-object" }, + { PANEL_OBJECT_APPLET, "gnome-applet" }, + { PANEL_OBJECT_ACTION, "action-applet" }, + { PANEL_OBJECT_MENU_BAR, "menu-bar" }, /* The following two are for backwards compatibility with 2.0.x */ { PANEL_OBJECT_LOCK, "lock-object" }, { PANEL_OBJECT_LOGOUT, "logout-object" }, @@ -1738,7 +1738,7 @@ char *id; char *dir; - key_type = (object_type == PANEL_OBJECT_BONOBO) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; + key_type = (object_type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; client = panel_gconf_get_client (); @@ -1787,7 +1787,7 @@ PanelGConfKeyType type; const char *id; - type = (applet_info->type) == PANEL_OBJECT_BONOBO ? PANEL_GCONF_APPLETS : + type = (applet_info->type) == PANEL_OBJECT_APPLET ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS; id = panel_applet_get_id (applet_info); @@ -1828,7 +1828,7 @@ key = panel_gconf_sprintf ("%s/position", object_dir); position = gconf_client_get_int (client, key, NULL); - + key = panel_gconf_sprintf ("%s/toplevel_id", object_dir); toplevel_id = gconf_client_get_string (client, key, NULL); @@ -2088,8 +2088,8 @@ for (l = existing_applets; l; l = l->next) { AppletInfo *info = l->data; - if ((type == PANEL_GCONF_APPLETS && info->type == PANEL_OBJECT_BONOBO) || - (type == PANEL_GCONF_OBJECTS && info->type != PANEL_OBJECT_BONOBO)) + if ((type == PANEL_GCONF_APPLETS && info->type == PANEL_OBJECT_APPLET) || + (type == PANEL_GCONF_OBJECTS && info->type != PANEL_OBJECT_APPLET)) sublist = g_slist_prepend (sublist, info); } Index: gnome-panel/panel-shell.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-shell.c,v retrieving revision 1.19 diff -u -u -r1.19 panel-shell.c --- gnome-panel/panel-shell.c 19 Nov 2005 14:49:09 -0000 1.19 +++ gnome-panel/panel-shell.c 30 Dec 2005 18:06:56 -0000 @@ -22,76 +22,130 @@ * Jacob Berkman */ -#include #include -#include #include +#include #include "panel-shell.h" #include "panel-util.h" +#include "panel-run-dialog.h" + +static gboolean impl_displayRunDialog (PanelShell *shell, GError *error); + +#include "panel-shell-glue.h" + +static void panel_shell_class_init (PanelShellClass *klass); +static void panel_shell_init (PanelShell *shell); + +struct _PanelShellPrivate { + DBusGConnection *connection; +}; + +#define PANEL_SHELL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_SHELL_TYPE, PanelShellPrivate)) + +#define PANEL_SHELL_PATH "/org/gnome/panel/shell" +#define PANEL_SHELL_SERVICE "org.gnome.panel.Shell" /* * PanelShell is a singleton. */ static PanelShell *panel_shell = NULL; -static Bonobo_RegistrationResult -panel_shell_bonobo_activation_register_for_display (const char *iid, - Bonobo_Unknown ref) -{ - const char *display_name; - GSList *reg_env ; - Bonobo_RegistrationResult result; - - display_name = gdk_display_get_name (gdk_display_get_default ()); - reg_env = bonobo_activation_registration_env_set (NULL, - "DISPLAY", - display_name); - result = bonobo_activation_register_active_server (iid, ref, reg_env); - bonobo_activation_registration_env_free (reg_env); - return result; +GType +panel_shell_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (PanelShellClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) panel_shell_class_init, + NULL, + NULL, + sizeof (PanelShell), + 0, + (GInstanceInitFunc) panel_shell_init + }; + + type = g_type_register_static (G_TYPE_OBJECT, "PanelShell", + &info, 0); + } + + return type; +} + +static void +panel_shell_error_dialog_show (const gchar *message) +{ + GtkWidget *dialog; + + dialog = panel_error_dialog ( + gdk_screen_get_default (), + "panel_shell_register_error", + FALSE, "%s", NULL, message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); } gboolean panel_shell_register (void) { - if (!panel_shell) { - Bonobo_RegistrationResult reg_res; - char *message = NULL; - - panel_shell = g_object_new (PANEL_SHELL_TYPE, NULL); - bonobo_object_set_immortal (BONOBO_OBJECT (panel_shell), TRUE); - - reg_res = panel_shell_bonobo_activation_register_for_display - ("OAFIID:GNOME_PanelShell", - BONOBO_OBJREF (panel_shell)); - - switch (reg_res) { - case Bonobo_ACTIVATION_REG_SUCCESS: - break; - case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE: - message = _("I've detected a panel already running,\n" - "and will now exit."); - break; - default: - message = g_strdup_printf (_("There was a problem registering the panel " - "with the bonobo-activation server.\n" - "The error code is: %d\n" - "The panel will now exit."), reg_res); - break; - } - - if (message) { - GtkWidget *dlg = panel_error_dialog ( - gdk_screen_get_default (), - "panel_shell_register_error", - FALSE, "%s", NULL, message); - - gtk_dialog_run (GTK_DIALOG (dlg)); - gtk_widget_destroy (dlg); - return FALSE; - } + DBusGProxy *bus_proxy; + GError *error = NULL; + gchar *message = NULL; + guint32 request_name_ret; + + if (panel_shell) + return TRUE; + + panel_shell = g_object_new (PANEL_SHELL_TYPE, NULL); + + panel_shell->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (error) { + g_warning (error->message); + panel_shell_error_dialog_show (error->message); + g_clear_error (&error); + + return FALSE; + } + + dbus_g_connection_register_g_object (panel_shell->priv->connection, + PANEL_SHELL_PATH, + G_OBJECT (panel_shell)); + + bus_proxy = dbus_g_proxy_new_for_name (panel_shell->priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if (!org_freedesktop_DBus_request_name (bus_proxy, PANEL_SHELL_SERVICE, + DBUS_NAME_FLAG_DO_NOT_QUEUE, + &request_name_ret, &error)) { + g_warning ("Failed to get name: %s\n", error->message); + message = g_strdup_printf (_("There was a problem registering the panel " + "with the session bus.\n" + "The error message is: %s\n" + "The panel will now exit."), error->message); + panel_shell_error_dialog_show (error->message); + g_free (message); + + g_clear_error (&error); + g_object_unref (bus_proxy); + + return FALSE; + } + + g_object_unref (bus_proxy); + + if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + panel_shell_error_dialog_show (_("I've detected a panel already running,\n" + "and will now exit.")); + + return FALSE; } return TRUE; @@ -100,35 +154,33 @@ void panel_shell_unregister (void) { - bonobo_activation_unregister_active_server ("OAFIID:GNOME_PanelShell", - BONOBO_OBJREF (panel_shell)); + dbus_g_connection_register_g_object (panel_shell->priv->connection, + PANEL_SHELL_PATH, + G_OBJECT (panel_shell)); } -static void -impl_displayRunDialog (PortableServer_Servant servant, - const CORBA_char *initial_string, - CORBA_Environment *ev) +static gboolean +impl_displayRunDialog (PanelShell *shell, GError *error) { - PanelShell *shell; - - shell = PANEL_SHELL (bonobo_object (servant)); - - g_message ("displayRunDialog: %s\n", initial_string); + panel_run_dialog_present (gdk_screen_get_default (), + gtk_get_current_event_time ()); + return TRUE; } static void panel_shell_class_init (PanelShellClass *klass) { - klass->epv.displayRunDialog = impl_displayRunDialog; + g_type_class_add_private (klass, sizeof (PanelShellPrivate)); + + dbus_g_object_type_install_info (PANEL_SHELL_TYPE, + &dbus_glib_panel_shell_object_info); } static void panel_shell_init (PanelShell *shell) { + shell->priv = PANEL_SHELL_GET_PRIVATE (shell); + shell->priv->connection = NULL; } -BONOBO_TYPE_FUNC_FULL (PanelShell, - GNOME_Vertigo_PanelShell, - BONOBO_OBJECT_TYPE, - panel_shell) Index: gnome-panel/panel-shell.h =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-shell.h,v retrieving revision 1.5 diff -u -u -r1.5 panel-shell.h --- gnome-panel/panel-shell.h 13 Nov 2003 12:31:02 -0000 1.5 +++ gnome-panel/panel-shell.h 30 Dec 2005 18:06:56 -0000 @@ -25,9 +25,7 @@ #ifndef __PANEL_SHELL_H__ #define __PANEL_SHELL_H__ -#include "GNOME_Panel.h" - -#include +#include #define PANEL_SHELL_TYPE (panel_shell_get_type ()) #define PANEL_SHELL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_SHELL_TYPE, PanelShell)) @@ -35,15 +33,21 @@ #define PANEL_IS_SHELL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_SHELL_TYPE)) #define PANEL_IS_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_SHELL_TYPE)) -typedef BonoboObject PanelShell; +typedef struct _PanelShell PanelShell; +typedef struct _PanelShellClass PanelShellClass; +typedef struct _PanelShellPrivate PanelShellPrivate; + +struct _PanelShell { + GObject parent; -typedef struct { - BonoboObjectClass parent_class; + PanelShellPrivate *priv; +}; - POA_GNOME_Vertigo_PanelShell__epv epv; -} PanelShellClass; +struct _PanelShellClass { + GObjectClass parent_class; +}; -GType panel_shell_get_type (void) G_GNUC_CONST; +GType panel_shell_get_type (void) G_GNUC_CONST; gboolean panel_shell_register (void); void panel_shell_unregister (void); Index: gnome-panel/panel-shell.xml =================================================================== RCS file: gnome-panel/panel-shell.xml diff -N gnome-panel/panel-shell.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnome-panel/panel-shell.xml 30 Dec 2005 18:06:56 -0000 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + Index: gnome-panel/panel-types.h =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-types.h,v retrieving revision 1.33 diff -u -u -r1.33 panel-types.h --- gnome-panel/panel-types.h 5 Mar 2003 01:11:35 -0000 1.33 +++ gnome-panel/panel-types.h 30 Dec 2005 18:06:56 -0000 @@ -4,16 +4,15 @@ #include #include -#include "GNOME_Panel.h" typedef enum { - PANEL_SIZE_XX_SMALL = GNOME_Vertigo_PANEL_XX_SMALL, - PANEL_SIZE_X_SMALL = GNOME_Vertigo_PANEL_X_SMALL, - PANEL_SIZE_SMALL = GNOME_Vertigo_PANEL_SMALL, - PANEL_SIZE_MEDIUM = GNOME_Vertigo_PANEL_MEDIUM, - PANEL_SIZE_LARGE = GNOME_Vertigo_PANEL_LARGE, - PANEL_SIZE_X_LARGE = GNOME_Vertigo_PANEL_X_LARGE, - PANEL_SIZE_XX_LARGE = GNOME_Vertigo_PANEL_XX_LARGE + PANEL_SIZE_XX_SMALL = 12, + PANEL_SIZE_X_SMALL = 24, + PANEL_SIZE_SMALL = 36, + PANEL_SIZE_MEDIUM = 48, + PANEL_SIZE_LARGE = 64, + PANEL_SIZE_X_LARGE = 80, + PANEL_SIZE_XX_LARGE = 128 } PanelSize; typedef enum { Index: gnome-panel/panel-widget.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-widget.c,v retrieving revision 1.382 diff -u -u -r1.382 panel-widget.c --- gnome-panel/panel-widget.c 22 Oct 2005 08:28:52 -0000 1.382 +++ gnome-panel/panel-widget.c 30 Dec 2005 18:06:56 -0000 @@ -2501,12 +2501,13 @@ (GCompareFunc)applet_data_compare); /*this will get done right on size allocate!*/ - if(panel->orient == GTK_ORIENTATION_HORIZONTAL) + if(panel->orient == GTK_ORIENTATION_HORIZONTAL) { gtk_fixed_put(GTK_FIXED(panel),applet, pos,0); - else + } else { gtk_fixed_put(GTK_FIXED(panel),applet, 0,pos); + } gtk_widget_queue_resize(GTK_WIDGET(panel)); @@ -2561,7 +2562,7 @@ focus_widget = gtk_window_get_focus (GTK_WINDOW (old_panel->toplevel)); gtk_widget_reparent (applet, GTK_WIDGET (new_panel)); - if (info && info->type == PANEL_OBJECT_BONOBO) + if (info && info->type == PANEL_OBJECT_APPLET) panel_applet_frame_set_panel (PANEL_APPLET_FRAME (ad->applet), new_panel); if (GTK_WIDGET_CAN_FOCUS (new_panel)) Index: gnome-panel/panel.c =================================================================== RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel.c,v retrieving revision 1.567 diff -u -u -r1.567 panel.c --- gnome-panel/panel.c 19 Nov 2005 14:49:09 -0000 1.567 +++ gnome-panel/panel.c 30 Dec 2005 18:06:56 -0000 @@ -70,7 +70,7 @@ orientation = panel_widget_get_applet_orientation (panel); switch (info->type) { - case PANEL_OBJECT_BONOBO: + case PANEL_OBJECT_APPLET: panel_applet_frame_change_orientation ( PANEL_APPLET_FRAME (info->widget), orientation); break; @@ -126,7 +126,7 @@ size_change (AppletInfo *info, PanelWidget *panel) { - if (info->type == PANEL_OBJECT_BONOBO) + if (info->type == PANEL_OBJECT_APPLET) panel_applet_frame_change_size ( PANEL_APPLET_FRAME (info->widget), panel->sz); } @@ -153,7 +153,7 @@ PanelWidget *panel) { switch (info->type) { - case PANEL_OBJECT_BONOBO: + case PANEL_OBJECT_APPLET: panel_applet_frame_change_background ( PANEL_APPLET_FRAME (info->widget), panel->background.type); break; Index: libpanel-applet/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/Makefile.am,v retrieving revision 1.24 diff -u -u -r1.24 Makefile.am --- libpanel-applet/Makefile.am 30 Oct 2004 21:04:58 -0000 1.24 +++ libpanel-applet/Makefile.am 30 Dec 2005 18:06:57 -0000 @@ -14,14 +14,21 @@ panel-applet.c \ panel-applet-gconf.c \ panel-applet-gconf.h \ - panel-applet-shell.c \ - panel-applet-shell.h \ + panel-applet-factory.c \ + panel-applet-factory.h \ + panel-applet-menu.c \ + panel-applet-menu.h \ panel-applet-private.h \ panel-applet-marshal.c \ panel-applet-marshal.h \ panel-applet-enums.c \ panel-applet-enums.h \ - $(CORBA_SRCLIST) + panel-applet-container.c \ + panel-applet-container.h \ + panel-applet-manager.c \ + panel-applet-manager.h \ + $(DBUS_SRCLIST) + libpanel_applet_2_la_LDFLAGS = \ -version-info $(LIB_PANEL_APPLET_LT_VERSION) \ @@ -32,20 +39,26 @@ libpanel_appletinclude_HEADERS = \ panel-applet.h \ + panel-applet-menu.h \ + panel-applet-container.h \ panel-applet-gconf.h \ - panel-applet-enums.h \ - GNOME_Panel.h + panel-applet-enums.h + +DBUS_SRCLIST = \ + panel-applet-factory-glue.h \ + panel-applet-menu-glue.h \ + panel-applet-glue.h + +panel-applet-factory-glue.h: panel-applet-factory.xml + dbus-binding-tool --prefix=panel_applet_factory --mode=glib-server --output=$@ $^ -CORBA_SRCLIST = \ - GNOME_Panel-stubs.c \ - GNOME_Panel-skels.c \ - GNOME_Panel-common.c \ - GNOME_Panel.h +panel-applet-menu-glue.h: panel-applet-menu.xml + dbus-binding-tool --prefix=panel_applet_container_menu --mode=glib-server --output=$@ $^ -$(CORBA_SRCLIST): $(top_srcdir)/idl/GNOME_Panel.idl $(ORBIT_IDL) - $(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/idl/GNOME_Panel.idl +panel-applet-glue.h: panel-applet.xml + dbus-binding-tool --prefix=panel_applet --mode=glib-server --output=$@ $^ -noinst_PROGRAMS = test-bonobo-applet +noinst_PROGRAMS = test-applet bin_PROGRAMS = panel-test-applets @@ -54,21 +67,23 @@ $(LIBPANEL_APPLET_LIBS) \ libpanel-applet-2.la -test_bonobo_applet_LDADD = \ +test_applet_LDADD = \ $(LIBPANEL_APPLET_LIBS) \ libpanel-applet-2.la BUILT_SOURCES = \ - $(CORBA_SRCLIST) \ + $(DBUS_SRCLIST) \ panel-applet-enums.c \ panel-applet-enums.h \ panel-applet-marshal.c \ panel-applet-marshal.h -$(libpanel_applet_2_la_OBJECTS) $(test_bonobo_applet_OBJECTS): $(BUILT_SOURCES) +$(libpanel_applet_2_la_OBJECTS) $(test_applet_OBJECTS): $(BUILT_SOURCES) EXTRA_DIST = \ - GNOME_Panel_TestApplet.server.in \ + panel-applet-factory.xml \ + panel-applet.xml \ + panel-applet-menu.xml \ panel-applet-marshal.list \ libpanelapplet-2.0.pc.in \ libpanelapplet-2.0-uninstalled.pc.in \ @@ -116,12 +131,6 @@ pkgconfig_DATA = libpanelapplet-2.0.pc CLEANFILES = $(BUILT_SOURCES) $(noinst_DATA) - -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_Panel_TestApplet.server.in -noinst_DATA = $(server_in_files:.server.in=.server) - -@INTLTOOL_SERVER_RULE@ dist-hook: cd $(distdir) ; rm -f $(CLEANFILES) Index: libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in,v retrieving revision 1.1 diff -u -u -r1.1 libpanelapplet-2.0-uninstalled.pc.in --- libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in 17 Feb 2004 11:22:27 -0000 1.1 +++ libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in 30 Dec 2005 18:06:57 -0000 @@ -5,7 +5,7 @@ Name: libpanel-applet-2 Description: libpanel-applet-2 -Requires: gtk+-2.0 libgnomeui-2.0 libbonoboui-2.0 +Requires: gtk+-2.0 libgnomeui-2.0 dbus-glib-1 Version: @VERSION@ Libs: ${pc_top_builddir}/${pcfiledir}/libpanel-applet-2.la Cflags: -I${pc_top_builddir}/${pcfiledir} Index: libpanel-applet/libpanelapplet-2.0.pc.in =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/libpanelapplet-2.0.pc.in,v retrieving revision 1.4 diff -u -u -r1.4 libpanelapplet-2.0.pc.in --- libpanel-applet/libpanelapplet-2.0.pc.in 30 Nov 2001 16:25:05 -0000 1.4 +++ libpanel-applet/libpanelapplet-2.0.pc.in 30 Dec 2005 18:06:57 -0000 @@ -5,7 +5,7 @@ Name: libpanel-applet-2 Description: libpanel-applet-2 -Requires: gtk+-2.0 libgnomeui-2.0 libbonoboui-2.0 +Requires: gtk+-2.0 libgnomeui-2.0 dbus-glib-1 Version: @VERSION@ Libs: -L${libdir} -lpanel-applet-2 Cflags: -I${includedir}/panel-2.0 Index: libpanel-applet/panel-applet-container.c =================================================================== RCS file: libpanel-applet/panel-applet-container.c diff -N libpanel-applet/panel-applet-container.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-container.c 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,1366 @@ +/* + * panel-applet-container.c: a container for applets. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#include +#include +#include +#include + +#include "panel-applet-container.h" +#include "panel-applet-marshal.h" + +static void panel_applet_container_init (PanelAppletContainer *container); +static void panel_applet_container_class_init (PanelAppletContainerClass *klass); +static void panel_applet_container_finalize (GObject *object); +static void panel_applet_container_dispose (GObject *object); + +static void panel_applet_container_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void panel_applet_container_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + +static gboolean panel_applet_container_expose (GtkWidget *widget, + GdkEventExpose *event); +static void panel_applet_container_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void panel_applet_container_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +static gboolean panel_applet_container_add_applet (PanelAppletContainer *container); + +struct _PanelAppletContainerPrivate { + DBusGConnection *connection; + DBusGProxy *applet; + DBusGProxy *applet_props; + DBusGProxy *bus_proxy; + + gchar *service; + GtkWidget *socket; + + gboolean disposed; + + GHashTable *notifiers; + + GdkRectangle handle_rect; + GtkAllocation child_allocation; + + GtkOrientation orient; + + guint has_handle : 1; + + /* Menu */ + DBusGProxy *menu; + GtkActionGroup *action_group; + + /* Activation */ + PanelAppletActivateCb callback; + gpointer user_data; + gboolean active; + GHashTable *prop_hash; +}; + +enum { + PROPERTY_0, + PROPERTY_ORIENT, + PROPERTY_HAS_HANDLE, + PROPERTY_HANDLE_RECT +}; + +enum { + APPLET_BROKEN, + LAST_SIGNAL +}; + +enum { + ACTION_NAME, + ACTION_STOCK_ID, + ACTION_LABEL, + ACTION_NULL +}; + +static guint panel_container_signals [LAST_SIGNAL]; + +typedef struct { + gchar *name; + GType type; +} PanelAppletPropertiesData; + +static const PanelAppletPropertiesData applet_properties [] = { + { "prefs-key", G_TYPE_STRING }, + { "orient", G_TYPE_UINT }, + { "size", G_TYPE_UINT }, + { "size-hints", G_TYPE_BOXED }, + { "background", G_TYPE_STRING }, + { "flags", G_TYPE_UINT }, + { "locked-down", G_TYPE_BOOLEAN }, + { NULL }, +}; + +#define PANEL_APPLET_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerPrivate)) + +#define HANDLE_SIZE 10 + +static GtkEventBoxClass *parent_class = NULL; + +GType +panel_applet_container_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (PanelAppletContainerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) panel_applet_container_class_init, + NULL, + NULL, + sizeof (PanelAppletContainer), + 0, + (GInstanceInitFunc) panel_applet_container_init + }; + + type = g_type_register_static (GTK_TYPE_EVENT_BOX, "PanelAppletContainer", + &info, 0); + } + + return type; +} + +static void +panel_applet_container_init (PanelAppletContainer *container) +{ + container->priv = PANEL_APPLET_CONTAINER_GET_PRIVATE (container); + + container->priv->socket = gtk_socket_new (); + + container->priv->disposed = FALSE; + + container->priv->notifiers = NULL; + + container->priv->orient = GTK_ORIENTATION_HORIZONTAL; + + container->priv->connection = NULL; + container->priv->applet = NULL; + container->priv->applet_props = NULL; + container->priv->bus_proxy = NULL; + container->priv->service = NULL; + container->priv->has_handle = FALSE; + + container->priv->menu = NULL; + container->priv->action_group = gtk_action_group_new ("MenuActions"); + + container->priv->callback = NULL; + container->priv->user_data = NULL; + container->priv->active = FALSE; + container->priv->prop_hash = NULL; + + gtk_container_add (GTK_CONTAINER (container), + container->priv->socket); + gtk_widget_show (container->priv->socket); +} + +static void +panel_applet_container_class_init (PanelAppletContainerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + g_type_class_add_private (klass, sizeof (PanelAppletContainerPrivate)); + + klass->applet_broken = NULL; + + widget_class->expose_event = panel_applet_container_expose; + widget_class->size_request = panel_applet_container_size_request; + widget_class->size_allocate = panel_applet_container_size_allocate; + + gobject_class->get_property = panel_applet_container_get_property; + gobject_class->set_property = panel_applet_container_set_property; + gobject_class->finalize = panel_applet_container_finalize; + gobject_class->dispose = panel_applet_container_dispose; + + g_object_class_install_property (gobject_class, + PROPERTY_ORIENT, + g_param_spec_uint ("orient", + "Orient", + "The Applet's containing Panel's orientation", + GTK_ORIENTATION_HORIZONTAL, + GTK_ORIENTATION_VERTICAL, + GTK_ORIENTATION_HORIZONTAL, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_HAS_HANDLE, + g_param_spec_boolean ("has-handle", + "HasHandle", + "If the Applet has handle", + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_HANDLE_RECT, + g_param_spec_pointer ("handle-rect", + "HandleRect", + "The Handle Rectangle", + G_PARAM_READWRITE)); + + panel_container_signals [APPLET_BROKEN] = + g_signal_new ("applet-broken", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (PanelAppletContainerClass, applet_broken), + NULL, + NULL, + panel_applet_marshal_VOID__VOID, + G_TYPE_NONE, + 0); +} + +static void +panel_applet_container_finalize (GObject *object) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (object); + + if (container->priv->service) { + g_free (container->priv->service); + container->priv->service = NULL; + } + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +static void +panel_applet_container_dispose (GObject *object) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (object); + + if (container->priv->disposed) + return; + + container->priv->disposed = TRUE; + + if (container->priv->bus_proxy) { + g_object_unref (container->priv->bus_proxy); + container->priv->bus_proxy = NULL; + } + + if (container->priv->applet) { + g_object_unref (container->priv->applet); + container->priv->applet = NULL; + } + + if (container->priv->applet_props) { + g_object_unref (container->priv->applet_props); + container->priv->applet_props = NULL; + } + + if (container->priv->menu) { + g_object_unref (container->priv->menu); + container->priv->menu = NULL; + } + + if (container->priv->notifiers) { + g_hash_table_destroy (container->priv->notifiers); + container->priv->notifiers = NULL; + } + + if (container->priv->action_group) { + g_object_unref (container->priv->action_group); + container->priv->action_group = NULL; + } + + if (container->priv->prop_hash) { + g_hash_table_destroy (container->priv->prop_hash); + container->priv->prop_hash = NULL; + } + + container->priv->active = FALSE; + + if (G_OBJECT_CLASS (parent_class)->dispose) + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +panel_applet_container_paint (GtkWidget *widget, + GdkRectangle *area) +{ + PanelAppletContainer *container; + + container = PANEL_APPLET_CONTAINER (widget); + + if (!container->priv->has_handle) + return; + + if (GTK_WIDGET_DRAWABLE (widget)) { + gtk_paint_handle ( + widget->style, widget->window, + GTK_WIDGET_STATE (widget), + GTK_SHADOW_OUT, + area, widget, "handlebox", + container->priv->handle_rect.x, + container->priv->handle_rect.y, + container->priv->handle_rect.width, + container->priv->handle_rect.height, + container->priv->orient); + } +} + +static gboolean +panel_applet_container_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + if (GTK_WIDGET_DRAWABLE (widget)) { + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + + panel_applet_container_paint (widget, &event->area); + + } + + return FALSE; +} + +static void +panel_applet_container_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + PanelAppletContainer *container; + GtkBin *bin; + GtkRequisition child_requisition; + + container = PANEL_APPLET_CONTAINER (widget); + bin = GTK_BIN (widget); + + if (!container->priv->has_handle) { + GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + return; + } + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width = child_requisition.width; + requisition->height = child_requisition.height; + } + + requisition->width += GTK_CONTAINER (widget)->border_width; + requisition->height += GTK_CONTAINER (widget)->border_width; + + switch (container->priv->orient) { + case GTK_ORIENTATION_HORIZONTAL: + requisition->width += HANDLE_SIZE; + break; + case GTK_ORIENTATION_VERTICAL: + requisition->height += HANDLE_SIZE; + break; + default: + g_assert_not_reached (); + break; + } +} + +static void +panel_applet_container_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + PanelAppletContainer *container; + GtkBin *bin; + GtkAllocation new_allocation; + + container = PANEL_APPLET_CONTAINER (widget); + bin = GTK_BIN (widget); + + if (!container->priv->has_handle) { + GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, + allocation); + return; + } + + widget->allocation = *allocation; + + container->priv->handle_rect.x = 0; + container->priv->handle_rect.y = 0; + + switch (container->priv->orient) { + case GTK_ORIENTATION_HORIZONTAL: + container->priv->handle_rect.width = HANDLE_SIZE; + container->priv->handle_rect.height = allocation->height; + + if (gtk_widget_get_direction (GTK_WIDGET (container)) != + GTK_TEXT_DIR_RTL) { + container->priv->handle_rect.x = 0; + new_allocation.x = HANDLE_SIZE; + } else { + container->priv->handle_rect.x = allocation->width - HANDLE_SIZE; + new_allocation.x = 0; + } + + new_allocation.y = 0; + new_allocation.width = allocation->width - HANDLE_SIZE; + new_allocation.height = allocation->height; + break; + case GTK_ORIENTATION_VERTICAL: + container->priv->handle_rect.width = allocation->width; + container->priv->handle_rect.height = HANDLE_SIZE; + + new_allocation.x = 0; + new_allocation.y = HANDLE_SIZE; + new_allocation.width = allocation->width; + new_allocation.height = allocation->height - HANDLE_SIZE; + break; + default: + g_assert_not_reached (); + break; + } + + new_allocation.width = MAX (1, new_allocation.width); + new_allocation.height = MAX (1, new_allocation.height); + + /* If the child allocation changed, that means that the frame is drawn + * in a new place, so we must redraw the entire widget. + */ + if (GTK_WIDGET_MAPPED (widget) && + (new_allocation.x != container->priv->child_allocation.x || + new_allocation.y != container->priv->child_allocation.y || + new_allocation.width != container->priv->child_allocation.width || + new_allocation.height != container->priv->child_allocation.height)) + gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); + + if (GTK_WIDGET_REALIZED (widget)) { + gdk_window_move_resize (widget->window, + allocation->x + GTK_CONTAINER (widget)->border_width, + allocation->y + GTK_CONTAINER (widget)->border_width, + MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0), + MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0)); + } + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &new_allocation); + + container->priv->child_allocation = new_allocation; +} + +static void +panel_applet_container_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (object); + + switch (prop_id) { + case PROPERTY_ORIENT: + g_value_set_uint (value, container->priv->orient); + break; + case PROPERTY_HAS_HANDLE: + g_value_set_boolean (value, container->priv->has_handle); + break; + case PROPERTY_HANDLE_RECT: + g_value_set_pointer (value, &container->priv->handle_rect); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +panel_applet_container_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (object); + + switch (prop_id) { + case PROPERTY_ORIENT: + container->priv->orient = g_value_get_uint (value); + break; + case PROPERTY_HAS_HANDLE: + container->priv->has_handle = g_value_get_boolean (value); + break; + case PROPERTY_HANDLE_RECT: { + GdkRectangle *rect; + + rect = (GdkRectangle *)g_value_get_pointer (value); + container->priv->handle_rect = *rect; + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + + +static GType +panel_applet_container_child_property_get_type (const gchar *property_name) +{ + gint i; + + g_assert (property_name != NULL); + + for (i = 0; applet_properties[i].name != NULL; i++) { + if (g_ascii_strcasecmp (applet_properties[i].name, + property_name) == 0) + return applet_properties[i].type; + } + + return -1; +} + +static void +panel_applet_container_set_applet_property (PanelAppletContainer *container, + const gchar *property, + const GValue *value) +{ + GError *error = NULL; + + if (!container->priv->applet_props) { + container->priv->applet_props = + dbus_g_proxy_new_from_proxy (container->priv->applet, + DBUS_INTERFACE_PROPERTIES, + NULL); + } + + if (!dbus_g_proxy_call (container->priv->applet_props, + "Set", &error, + G_TYPE_STRING, dbus_g_proxy_get_path (container->priv->applet_props), + G_TYPE_STRING, property, + G_TYPE_VALUE, value, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } +} + +static void +panel_applet_container_child_set_valist (PanelAppletContainer *container, + DBusGProxy *applet_proxy, + const gchar *first_prop_name, + va_list var_args) +{ + const gchar *name; + + name = first_prop_name; + while (name) { + GValue value = { 0, }; + GType type; + gchar *error = NULL; + + type = panel_applet_container_child_property_get_type (name); + if (type == -1) { + g_warning ("%s: Applet has no child property named `%s'", + G_STRLOC, name); + break; + } + + g_value_init (&value, type); + G_VALUE_COLLECT (&value, var_args, 0, &error); + if (error) { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); + g_value_unset (&value); + + break; + } + + panel_applet_container_set_applet_property (container, + name, + &value); + + g_value_unset (&value); + name = va_arg (var_args, gchar*); + } +} + +static void +panel_applet_container_get_applet_property (PanelAppletContainer *container, + const gchar *property, + GValue *value) +{ + GError *error = NULL; + + if (!container->priv->applet_props) { + container->priv->applet_props = + dbus_g_proxy_new_from_proxy (container->priv->applet, + DBUS_INTERFACE_PROPERTIES, + NULL); + } + + if (!dbus_g_proxy_call (container->priv->applet_props, + "Get", &error, + G_TYPE_STRING, dbus_g_proxy_get_path (container->priv->applet_props), + G_TYPE_STRING, property, + G_TYPE_INVALID, + G_TYPE_VALUE, value, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } +} + +static void +panel_applet_container_child_get_valist (PanelAppletContainer *container, + DBusGProxy *applet_proxy, + const gchar *first_prop_name, + va_list var_args) +{ + const gchar *name; + + name = first_prop_name; + while (name) { + GValue value = { 0, }; + GType type; + gchar *error = NULL; + + type = panel_applet_container_child_property_get_type (name); + if (type == -1) { + g_warning ("%s: Applet has no child property named `%s'", + G_STRLOC, name); + break; + } + + panel_applet_container_get_applet_property (container, + name, + &value); + + G_VALUE_LCOPY (&value, var_args, 0, &error); + if (error) { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); + g_value_unset (&value); + + return; + } + + g_value_unset (&value); + name = va_arg (var_args, gchar*); + } +} + +GtkWidget * +panel_applet_container_new (void) +{ + GtkWidget *container; + + container = GTK_WIDGET (g_object_new (PANEL_TYPE_APPLET_CONTAINER, NULL)); + + return container; +} + +static void +panel_applet_container_menu_activate (DBusGProxy *proxy, const gchar *action_name, gpointer user_data) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (user_data); + GtkAction *action; + + g_return_if_fail (action_name != NULL); + + action = gtk_action_group_get_action (container->priv->action_group, action_name); + + if (action) { + g_signal_emit_by_name (action, "activate", NULL); + } +} + +static void +panel_applet_container_child_property_changed (DBusGProxy *proxy, const gchar *property, gpointer user_data) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (user_data); + GClosure *closure = NULL; + GValue value = {0, }; + GValue param = {0, }; + GArray *params; + gint i; + + g_return_if_fail (property != NULL); + + if (!container->priv->notifiers) + return; + + closure = g_hash_table_lookup (container->priv->notifiers, property); + + if (!closure) + return; + + panel_applet_container_get_applet_property (container, + property, + &value); + + params = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 2); + + param.g_type = 0; + g_value_init (¶m, G_TYPE_OBJECT); + g_value_set_object (¶m, G_OBJECT (container)); + g_array_append_val (params, param); + + param.g_type = 0; + g_value_init (¶m, G_TYPE_VALUE); + g_value_set_boxed (¶m, &value); + g_array_append_val (params, param); + + g_closure_invoke (closure, NULL, + params->len, + (GValue *) params->data, + NULL); + + for (i = 0; i < params->len; i++) + g_value_unset (&g_array_index (params, GValue, i)); + + g_array_free (params, TRUE); +} + +static gboolean +panel_applet_container_add_applet (PanelAppletContainer *container) +{ + GError *error = NULL; + guint32 xid = 0; + gint screen; + + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (container))) + return FALSE; + + screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket)); + + if (!dbus_g_proxy_call (container->priv->applet, + "GetXid", &error, + G_TYPE_INT, screen, + G_TYPE_INVALID, + G_TYPE_UINT, &xid, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + + return FALSE; + } + + gtk_socket_add_id (GTK_SOCKET (container->priv->socket), xid); + + return TRUE; +} + +static void +set_property_from_hash (const gchar *key, GValue *value, PanelAppletContainer *container) +{ + panel_applet_container_set_applet_property (container, + key, + value); + g_value_unset (value); +} + +static void +panel_applet_container_get_applet_async_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (user_data); + GError *error = NULL; + DBusGProxy *applet_proxy = NULL; + + dbus_g_proxy_end_call (proxy, call, &error, + DBUS_TYPE_G_PROXY, &applet_proxy, + G_TYPE_INVALID); + + if (DBUS_IS_G_PROXY (applet_proxy)) { + dbus_g_proxy_set_interface (applet_proxy, "org.gnome.panel.applet.PanelApplet"); + container->priv->applet = applet_proxy; + container->priv->active = TRUE; + + if (container->priv->prop_hash) { + g_hash_table_foreach (container->priv->prop_hash, + (GHFunc) set_property_from_hash, + container); + g_hash_table_destroy (container->priv->prop_hash); + container->priv->prop_hash = NULL; + } + + if (container->priv->callback) { + if (!container->priv->callback (container, error, container->priv->user_data)) + return; + } + + dbus_g_proxy_add_signal (container->priv->applet, "property_changed", + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (container->priv->applet, "property_changed", + G_CALLBACK (panel_applet_container_child_property_changed), + (gpointer) container, + NULL); + + if (GTK_WIDGET_REALIZED (container)) + panel_applet_container_add_applet (container); + } else { + if (container->priv->prop_hash) + g_hash_table_destroy (container->priv->prop_hash); + container->priv->prop_hash = NULL; + + if (container->priv->callback) { + if (!container->priv->callback (container, error, container->priv->user_data)) + return; + } + } +} + +static void +panel_applet_container_name_owner_changed (DBusGProxy *proxy, + const gchar *name, + const gchar *prev_owner, + const gchar *new_owner, + gpointer user_data) +{ + PanelAppletContainer *container = PANEL_APPLET_CONTAINER (user_data); + + if (!container->priv->active) + return; + + if (g_strcasecmp (container->priv->service, name) != 0) + return; + + if (g_ascii_strcasecmp (new_owner, "") == 0) { + container->priv->active = FALSE; + g_signal_emit (container, + panel_container_signals [APPLET_BROKEN], + 0); + } +} + +static DBusGProxyCall * +panel_applet_container_get_applet (PanelAppletContainer *container, + const gchar *applet_id, + GError **error) +{ + DBusGProxy *proxy; + DBusGProxyCall *call; + gchar *service, *path; + gchar **ids = NULL; + const gchar *aid, *fid; + + if (!container->priv->connection) { + container->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, error); + if (!container->priv->connection) { + g_warning ((*error)->message); + + return NULL; + } + } + + fid = aid = applet_id; + if (g_strrstr (applet_id, "::")) { + ids = g_strsplit (applet_id, "::", 2); + fid = ids[0]; + aid = ids[1]; + } + + path = g_strdup_printf ("/org/gnome/panel/applet/%s/Factory", fid); + service = g_strdup_printf ("org.gnome.panel.applet.%s", fid); + + if (container->priv->service) + g_free (container->priv->service); + container->priv->service = g_strdup (service); + + proxy = dbus_g_proxy_new_for_name (container->priv->connection, + service, + path, + "org.gnome.panel.applet.PanelAppletFactory"); + + g_free (path); + g_free (service); + + if (container->priv->bus_proxy) + g_object_unref (container->priv->bus_proxy); + + container->priv->bus_proxy = dbus_g_proxy_new_for_name (container->priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + dbus_g_proxy_add_signal (container->priv->bus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (container->priv->bus_proxy, "NameOwnerChanged", + G_CALLBACK (panel_applet_container_name_owner_changed), + container, NULL); + + call = dbus_g_proxy_begin_call (proxy, "GetApplet", + panel_applet_container_get_applet_async_cb, + container, NULL, + G_TYPE_STRING, aid, + G_TYPE_INVALID); + g_strfreev (ids); + + return call; +} + +static void +panel_applet_container_create_applet_properties (PanelAppletContainer *container, + const gchar *first_prop_name, + va_list var_args) +{ + const gchar *name; + + if (container->priv->prop_hash) + g_hash_table_destroy (container->priv->prop_hash); + + container->priv->prop_hash = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + + name = first_prop_name; + while (name) { + GValue *value; + GType type; + gchar *error = NULL; + + type = panel_applet_container_child_property_get_type (name); + if (type == -1) { + g_warning ("%s: Applet has no child property named `%s'", + G_STRLOC, name); + break; + } + + value = g_new0 (GValue, 1); + g_value_init (value, type); + G_VALUE_COLLECT (value, var_args, 0, &error); + if (error) { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); + g_value_unset (value); + g_free (value); + + break; + } + + g_hash_table_insert (container->priv->prop_hash, + g_strdup (name), value); + + name = va_arg (var_args, gchar*); + } +} + +void +panel_applet_container_add_with_properties (PanelAppletContainer *container, + const gchar *applet_id, + PanelAppletActivateCb callback, + gpointer user_data, + const gchar *first_prop_name, + ...) +{ + DBusGProxyCall *call; + GError *error = NULL; + va_list var_args; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (applet_id != NULL && first_prop_name != NULL); + + container->priv->callback = callback; + container->priv->user_data = user_data; + + va_start (var_args, first_prop_name); + panel_applet_container_create_applet_properties (container, + first_prop_name, + var_args); + va_end (var_args); + + call = panel_applet_container_get_applet (container, applet_id, &error); + + if (!call && container->priv->callback) + container->priv->callback (container, error, user_data); +} + +void +panel_applet_container_add (PanelAppletContainer *container, + const gchar *applet_id, + PanelAppletActivateCb callback, + gpointer user_data) +{ + DBusGProxyCall *call; + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (applet_id != NULL); + + container->priv->callback = callback; + container->priv->user_data = user_data; + + if (container->priv->prop_hash) { + g_hash_table_destroy (container->priv->prop_hash); + container->priv->prop_hash = NULL; + } + + call = panel_applet_container_get_applet (container, applet_id, &error); + + if (!call && container->priv->callback) + container->priv->callback (container, error, user_data); +} + +void +panel_applet_container_child_set (PanelAppletContainer *container, + const gchar *first_prop_name, + ...) +{ + va_list var_args; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + + if (!DBUS_IS_G_PROXY (container->priv->applet)) + return; + + va_start (var_args, first_prop_name); + panel_applet_container_child_set_valist (container, + container->priv->applet, + first_prop_name, + var_args); + va_end (var_args); +} + +void +panel_applet_container_child_get (PanelAppletContainer *container, + const gchar *first_prop_name, + ...) +{ + va_list var_args; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + + if (!DBUS_IS_G_PROXY (container->priv->applet)) + return; + + va_start (var_args, first_prop_name); + panel_applet_container_child_get_valist (container, + container->priv->applet, + first_prop_name, + var_args); + va_end (var_args); +} + +void +panel_applet_container_child_notify_add (PanelAppletContainer *container, + const gchar *property, + GCallback notify_func, + gpointer user_data) +{ + GType type; + GClosure *closure; + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (property != NULL && notify_func != NULL); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + type = panel_applet_container_child_property_get_type (property); + if (type == -1) { + g_warning ("%s: Applet has no child property named `%s'", + G_STRLOC, property); + return; + } + + if (!container->priv->notifiers) { + container->priv->notifiers = + g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify)g_closure_unref); + } + + closure = g_cclosure_new (notify_func, user_data, NULL); + g_closure_set_marshal (closure, + panel_applet_marshal_VOID__BOXED); + g_hash_table_insert (container->priv->notifiers, + g_strdup (property), closure); + + if (!dbus_g_proxy_call (container->priv->applet, + "NotifyAdd", &error, + G_TYPE_STRING, property, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } +} + +static gboolean +panel_applet_container_menu_setup (PanelAppletContainer *container) +{ + DBusGProxy *proxy; + GError *error = NULL; + gchar *path; + const gchar *applet_path; + + if (!container->priv->connection) { + container->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (!container->priv->connection) { + g_warning (error->message); + g_error_free (error); + + return FALSE; + } + } + + applet_path = dbus_g_proxy_get_path (container->priv->applet); + path = g_strdup_printf ("%s/Menu", applet_path); + + proxy = dbus_g_proxy_new_for_name (container->priv->connection, + container->priv->service, + path, + "org.gnome.panel.applet.PanelAppletMenu"); + if (!DBUS_IS_G_PROXY (proxy)) { + g_free (path); + return FALSE; + } + + if (container->priv->menu) + g_object_unref (container->priv->menu); + + container->priv->menu = proxy; + dbus_g_proxy_add_signal (container->priv->menu, "activate", + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (container->priv->menu, "activate", + G_CALLBACK (panel_applet_container_menu_activate), + (gpointer) container, + NULL); + g_free (path); + + return TRUE; +} + +void +panel_applet_container_menu_add_ui_from_string (PanelAppletContainer *container, + const gchar *xml) +{ + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (xml != NULL); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + if (!container->priv->menu) { + if (!panel_applet_container_menu_setup (container)) + return; + } + + if (!dbus_g_proxy_call (container->priv->menu, + "SetupUI", &error, + G_TYPE_STRING, xml, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + + return; + } +} + +void +panel_applet_container_menu_add_ui_from_file (PanelAppletContainer *container, + const gchar *opt_datadir, + const gchar *file, + const gchar *opt_ui_dirname) +{ + gchar *ui_dirname = NULL; + gchar *filename; + gchar *xml = NULL; + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (file != NULL); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + if (!opt_datadir) + opt_datadir = PANEL_APPLET_DATADIR; + + if (!opt_ui_dirname) + ui_dirname = g_build_filename ("gnome-2.0", "ui", NULL); + + filename = g_build_filename (opt_datadir, ui_dirname, file, NULL); + + if (g_file_get_contents (filename, &xml, NULL, &error)) { + panel_applet_container_menu_add_ui_from_string ( + container, xml); + } else { + g_warning ("%s", error->message); + g_clear_error (&error); + } + + g_free (filename); + g_free (ui_dirname); +} + +void +panel_applet_container_menu_add_actions (PanelAppletContainer *container, + const GtkActionEntry *actions, + guint n_entries, + gpointer user_data) +{ + GPtrArray *array; + gchar **strs; + GtkActionEntry entry; + GError *error = NULL; + gint i; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + if (!container->priv->menu) { + if (!panel_applet_container_menu_setup (container)) + return; + } + + array = g_ptr_array_new (); + + for (i = 0; i < n_entries; i++) { + entry = actions[i]; + + strs = g_new0 (gchar *, ACTION_NULL + 1); + + strs[ACTION_NAME] = (entry.name != NULL) ? g_strdup (entry.name) : ""; + strs[ACTION_STOCK_ID] = (entry.stock_id != NULL) ? g_strdup (entry.stock_id) : ""; + strs[ACTION_LABEL] = (entry.label != NULL) ? g_strdup (entry.label) : ""; + strs[ACTION_NULL] = NULL; + + g_ptr_array_add (array, strs); + } + + gtk_action_group_add_actions (container->priv->action_group, + actions, n_entries, user_data); + + if (!dbus_g_proxy_call (container->priv->menu, + "AddActions", &error, + dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), + array, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } + + for (i = 0; i < array->len; i++) + g_free (g_ptr_array_index (array, i)); + + g_ptr_array_free (array, TRUE); +} + +void +panel_applet_container_menu_add_toggle_actions (PanelAppletContainer *container, + const GtkToggleActionEntry *actions, + guint n_entries, + gpointer user_data) +{ + GPtrArray *array; + gchar **strs; + GtkToggleActionEntry entry; + GError *error = NULL; + gint i; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + if (!container->priv->menu) { + if (!panel_applet_container_menu_setup (container)) + return; + } + + array = g_ptr_array_new (); + + for (i = 0; i < n_entries; i++) { + entry = actions[i]; + + strs = g_new0 (gchar *, ACTION_NULL + 1); + + strs[ACTION_NAME] = (entry.name != NULL) ? g_strdup (entry.name) : ""; + strs[ACTION_STOCK_ID] = (entry.stock_id != NULL) ? g_strdup (entry.stock_id) : ""; + strs[ACTION_LABEL] = (entry.label != NULL) ? g_strdup (entry.label) : ""; + strs[ACTION_NULL] = NULL; + + g_ptr_array_add (array, strs); + } + + gtk_action_group_add_toggle_actions (container->priv->action_group, + actions, n_entries, user_data); + + if (!dbus_g_proxy_call (container->priv->menu, + "AddToggleActions", &error, + dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), + array, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } + + for (i = 0; i < array->len; i++) + g_free (g_ptr_array_index (array, i)); + + g_ptr_array_free (array, TRUE); +} + +void +panel_applet_container_menu_set_property (PanelAppletContainer *container, + const gchar *action, + const gchar *property, + const GValue *value) +{ + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (action != NULL && property != NULL); + g_return_if_fail (G_IS_VALUE (value)); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->menu)); + + if (!dbus_g_proxy_call (container->priv->menu, + "SetActionProperty", &error, + G_TYPE_STRING, action, + G_TYPE_STRING, property, + G_TYPE_VALUE, value, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } +} + +void +panel_applet_container_menu_popup (PanelAppletContainer *container, + guint button, + guint32 time) +{ + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (DBUS_IS_G_PROXY (container->priv->applet)); + + if (!dbus_g_proxy_call (container->priv->applet, + "PopupMenu", &error, + G_TYPE_UINT, button, + G_TYPE_UINT, time, + G_TYPE_INVALID, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + } +} Index: libpanel-applet/panel-applet-container.h =================================================================== RCS file: libpanel-applet/panel-applet-container.h diff -N libpanel-applet/panel-applet-container.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-container.h 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,112 @@ +/* + * panel-applet-container.h: a container for applets. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#ifndef __PANEL_APPLET_CONTAINER_H__ +#define __PANEL_APPLET_CONTAINER_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define PANEL_TYPE_APPLET_CONTAINER (panel_applet_container_get_type ()) +#define PANEL_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainer)) +#define PANEL_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerClass)) +#define PANEL_IS_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_CONTAINER)) +#define PANEL_IS_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_CONTAINER)) +#define PANEL_APPLET_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerClass)) + +typedef struct _PanelAppletContainer PanelAppletContainer; +typedef struct _PanelAppletContainerClass PanelAppletContainerClass; +typedef struct _PanelAppletContainerPrivate PanelAppletContainerPrivate; + +typedef gboolean (*PanelAppletActivateCb) (PanelAppletContainer *container, + GError *error, + gpointer user_data); + +struct _PanelAppletContainer { + GtkEventBox parent; + + PanelAppletContainerPrivate *priv; +}; + +struct _PanelAppletContainerClass { + GtkEventBoxClass parent_class; + + void (*applet_broken) (PanelAppletContainer *container); +}; + +GType panel_applet_container_get_type (void) G_GNUC_CONST; +GtkWidget *panel_applet_container_new (void); + + +void panel_applet_container_add (PanelAppletContainer *container, + const gchar *applet_id, + PanelAppletActivateCb callback, + gpointer user_data); +void panel_applet_container_add_with_properties (PanelAppletContainer *container, + const gchar *applet_id, + PanelAppletActivateCb callback, + gpointer user_data, + const gchar *first_prop_name, + ...); +void panel_applet_container_child_set (PanelAppletContainer *container, + const gchar *first_prop_name, + ...); +void panel_applet_container_child_get (PanelAppletContainer *container, + const gchar *first_prop_name, + ...); +void panel_applet_container_child_notify_add (PanelAppletContainer *container, + const gchar *property, + GCallback notify_func, + gpointer user_data); +/* Menu */ +void panel_applet_container_menu_add_ui_from_string (PanelAppletContainer *container, + const gchar *xml); +void panel_applet_container_menu_add_ui_from_file (PanelAppletContainer *container, + const gchar *opt_datadir, + const gchar *file, + const gchar *opt_ui_dirname); +void panel_applet_container_menu_add_actions (PanelAppletContainer *container, + const GtkActionEntry *actions, + guint n_entries, + gpointer user_data); +void panel_applet_container_menu_add_toggle_actions (PanelAppletContainer *container, + const GtkToggleActionEntry *actions, + guint n_entries, + gpointer user_data); +void panel_applet_container_menu_set_property (PanelAppletContainer *container, + const gchar *action, + const gchar *property, + const GValue *value); +void panel_applet_container_menu_popup (PanelAppletContainer *container, + guint button, + guint32 time); + + +G_END_DECLS + +#endif /* __PANEL_APPLET_CONTAINER_H__ */ Index: libpanel-applet/panel-applet-factory.c =================================================================== RCS file: libpanel-applet/panel-applet-factory.c diff -N libpanel-applet/panel-applet-factory.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-factory.c 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,264 @@ +/* + * panel-applet-factory.c: panel applet factory + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#include +#include + +#include "panel-applet-factory.h" + +static void panel_applet_factory_init (PanelAppletFactory *factory); +static void panel_applet_factory_class_init (PanelAppletFactoryClass *klass); +static void panel_applet_factory_finalize (GObject *object); + +static gboolean panel_applet_factory_get_applet (PanelAppletFactory *factory, + const gchar *IN_applet_id, + gchar **OUT_applet, + GError **error); + +#include "panel-applet-factory-glue.h" + +struct _PanelAppletFactoryPrivate { + DBusGConnection *connection; + + GHashTable *applets; + + GType applet_type; + gchar *applet_id; + GClosure *closure; +}; + +#define PANEL_APPLET_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactoryPrivate)) + +static GObjectClass *parent_class = NULL; + +GType +panel_applet_factory_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (PanelAppletFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) panel_applet_factory_class_init, + NULL, + NULL, + sizeof (PanelAppletFactory), + 0, + (GInstanceInitFunc) panel_applet_factory_init + }; + + type = g_type_register_static (G_TYPE_OBJECT, "PanelAppletFactory", + &info, 0); + } + + return type; +} + +static void +panel_applet_factory_init (PanelAppletFactory *factory) +{ + factory->priv = PANEL_APPLET_FACTORY_GET_PRIVATE (factory); + + factory->priv->connection = NULL; + factory->priv->applets = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, NULL); + + factory->priv->applet_type = 0; + factory->priv->applet_id = NULL; + factory->priv->closure = NULL; +} + +static void +panel_applet_factory_class_init (PanelAppletFactoryClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + g_type_class_add_private (klass, sizeof (PanelAppletFactoryPrivate)); + + dbus_g_object_type_install_info (PANEL_TYPE_APPLET_FACTORY, + &dbus_glib_panel_applet_factory_object_info); + + object_class->finalize = panel_applet_factory_finalize; +} + +static void +panel_applet_factory_finalize (GObject *object) +{ + PanelAppletFactory *factory = PANEL_APPLET_FACTORY (object); + + if (factory->priv->applet_id) { + g_free (factory->priv->applet_id); + factory->priv->applet_id = NULL; + } + + if (factory->priv->applets) { + g_hash_table_destroy (factory->priv->applets); + factory->priv->applets = NULL; + } + + if (factory->priv->closure) { + g_closure_unref (factory->priv->closure); + factory->priv->closure = NULL; + } + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +static void +panel_applet_factory_applet_removed (PanelAppletFactory *factory, GObject *object) +{ + g_hash_table_remove (factory->priv->applets, object); + + if (g_hash_table_size (factory->priv->applets) == 0) { + g_object_unref (factory); + gtk_main_quit (); + } +} + +static gboolean +panel_applet_factory_get_applet (PanelAppletFactory *factory, + const gchar *IN_applet_id, + gchar **OUT_applet, + GError **error) +{ + PanelApplet *applet; + PanelAppletMenu *menu; + static gint id = 0; + gchar *path; + gchar *menu_path; + + path = g_strdup_printf ("/org/gnome/panel/applet/%s/%d", IN_applet_id, id++); + + applet = PANEL_APPLET (g_object_new (factory->priv->applet_type, + "id", IN_applet_id, + "closure", g_closure_ref (factory->priv->closure), + NULL)); + + g_hash_table_insert (factory->priv->applets, applet, applet); + dbus_g_connection_register_g_object (factory->priv->connection, path, G_OBJECT (applet)); + g_object_weak_ref (G_OBJECT (applet), (GWeakNotify)panel_applet_factory_applet_removed, factory); + + menu = panel_applet_get_menu (applet); + menu_path = g_strdup_printf ("%s/Menu", path); + dbus_g_connection_register_g_object (factory->priv->connection, menu_path, G_OBJECT (menu)); + g_free (menu_path); + + *OUT_applet = path; + + return TRUE; +} + +static gboolean +panel_applet_factory_activate_service (PanelAppletFactory *factory) +{ + gchar *service, *path; + DBusGProxy *bus_proxy; + GError *error = NULL; + guint32 request_name_ret; + + if (!factory->priv->connection) { + factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (error) { + g_warning (error->message); + g_clear_error (&error); + + return FALSE; + } + } + + path = g_strdup_printf ("/org/gnome/panel/applet/%s/Factory", + factory->priv->applet_id); + service = g_strdup_printf ("org.gnome.panel.applet.%s", + factory->priv->applet_id); + + dbus_g_connection_register_g_object (factory->priv->connection, path, + G_OBJECT (factory)); + + bus_proxy = dbus_g_proxy_new_for_name (factory->priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if (!org_freedesktop_DBus_request_name (bus_proxy, service, + DBUS_NAME_FLAG_DO_NOT_QUEUE, + &request_name_ret, &error)) { + g_warning ("Failed to get name: %s\n", error->message); + g_clear_error (&error); + g_free (path); + g_free (service); + g_object_unref (bus_proxy); + + return FALSE; + } + + g_free (path); + g_object_unref (bus_proxy); + + if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_warning ("Service %s is already running", service); + g_free (service); + + return FALSE; + } + + g_free (service); + + return TRUE; +} + +gint +panel_applet_factory_main (const gchar *iid, + GType type, + PanelAppletFactoryCallback callback, + gpointer user_data) +{ + PanelAppletFactory *factory; + + g_return_val_if_fail (iid != NULL, 1); + + factory = g_object_new (PANEL_TYPE_APPLET_FACTORY, NULL); + + factory->priv->applet_type = type; + factory->priv->applet_id = g_strdup (iid); + + if (callback) + factory->priv->closure = g_cclosure_new (G_CALLBACK (callback), user_data, NULL); + + if (panel_applet_factory_activate_service (factory)) { + gtk_main (); + + return 0; + } + + g_object_unref (factory); + + return 1; +} + Index: libpanel-applet/panel-applet-factory.h =================================================================== RCS file: libpanel-applet/panel-applet-factory.h diff -N libpanel-applet/panel-applet-factory.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-factory.h 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,68 @@ +/* + * panel-applet-factory.h: panel applet factory. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#ifndef __PANEL_APPLET_FACTORY_H__ +#define __PANEL_APPLET_FACTORY_H__ + +#include + +#include "panel-applet.h" + +G_BEGIN_DECLS + +#define PANEL_TYPE_APPLET_FACTORY (panel_applet_factory_get_type ()) +#define PANEL_APPLET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactory)) +#define PANEL_APPLET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactoryClass)) +#define PANEL_IS_APPLET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_FACTORY)) +#define PANEL_IS_APPLET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_FACTORY)) +#define PANEL_APPLET_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactoryClass)) + +typedef struct _PanelAppletFactory PanelAppletFactory; +typedef struct _PanelAppletFactoryClass PanelAppletFactoryClass; +typedef struct _PanelAppletFactoryPrivate PanelAppletFactoryPrivate; + +typedef gboolean (*PanelAppletFactoryCallback) (PanelApplet *applet, + const gchar *iid, + gpointer user_data); + +struct _PanelAppletFactory { + GObject parent; + + PanelAppletFactoryPrivate *priv; +}; + +struct _PanelAppletFactoryClass { + GObjectClass parent_class; +}; + +GType panel_applet_factory_get_type (void) G_GNUC_CONST; +PanelAppletFactory *panel_applet_factory_new (void); + +gint panel_applet_factory_main (const gchar *iid, + GType type, + PanelAppletFactoryCallback callback, + gpointer user_data); +G_END_DECLS + +#endif /* __PANEL_APPLET_FACTORY_H__ */ Index: libpanel-applet/panel-applet-factory.xml =================================================================== RCS file: libpanel-applet/panel-applet-factory.xml diff -N libpanel-applet/panel-applet-factory.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-factory.xml 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + Index: libpanel-applet/panel-applet-manager.c =================================================================== RCS file: libpanel-applet/panel-applet-manager.c diff -N libpanel-applet/panel-applet-manager.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-manager.c 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,236 @@ +/* + * panel-applet-manager.c: panel applet manager. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#include +#include + +#include "panel-applet-manager.h" + +static void panel_applet_manager_init (PanelAppletManager *manager); +static void panel_applet_manager_class_init (PanelAppletManagerClass *klass); +static void panel_applet_manager_finalize (GObject *object); + +struct _PanelAppletManagerPrivate { + DBusGConnection *connection; + DBusGProxy *proxy; +}; + +#define PANEL_APPLET_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_MANAGER, PanelAppletManagerPrivate)) + +#define APPLETS_MANAGER_PATH "/org/gnome/panel/AppletsManager" +#define APPLETS_MANAGER_SERVICE "org.gnome.panel.AppletsManager" + +static GObjectClass *parent_class = NULL; + +enum { + APPLET_ID, + APPLET_NAME, + APPLET_COMMENT, + APPLET_ICON +}; + +GType +panel_applet_manager_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (PanelAppletManagerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) panel_applet_manager_class_init, + NULL, + NULL, + sizeof (PanelAppletManager), + 0, + (GInstanceInitFunc) panel_applet_manager_init + }; + + type = g_type_register_static (G_TYPE_OBJECT, "PanelAppletManager", + &info, 0); + } + + return type; +} + +static void +panel_applet_manager_init (PanelAppletManager *manager) +{ + GError *error = NULL; + + manager->priv = PANEL_APPLET_MANAGER_GET_PRIVATE (manager); + + manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (error) { + g_warning (error->message); + g_clear_error (&error); + manager->priv->connection = NULL; + manager->priv->proxy = NULL; + + return; + } + + manager->priv->proxy = dbus_g_proxy_new_for_name (manager->priv->connection, + APPLETS_MANAGER_SERVICE, + APPLETS_MANAGER_PATH, + APPLETS_MANAGER_SERVICE); +} + +static void +panel_applet_manager_class_init (PanelAppletManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + g_type_class_add_private (klass, sizeof (PanelAppletManagerPrivate)); + + object_class->finalize = panel_applet_manager_finalize; +} + +static void +panel_applet_manager_finalize (GObject *object) +{ + PanelAppletManager *manager = PANEL_APPLET_MANAGER (object); + + if (manager->priv->proxy) { + g_object_unref (manager->priv->proxy); + manager->priv->proxy = NULL; + } + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +PanelAppletManager * +panel_applet_manager_new (void) +{ + PanelAppletManager *manager; + + manager = PANEL_APPLET_MANAGER (g_object_new (PANEL_TYPE_APPLET_MANAGER, NULL)); + + return manager; +} + +static PanelAppletInfo * +panel_applet_info_new (gchar **strs) +{ + PanelAppletInfo *info; + + g_assert (strs != NULL); + + info = g_new0 (PanelAppletInfo, 1); + + info->id = (strlen (strs[APPLET_ID]) > 0) ? + g_strdup (strs[APPLET_ID]) : NULL; + info->name = (strlen (strs[APPLET_NAME]) > 0) ? + g_strdup (strs[APPLET_NAME]) : NULL; + info->comment = (strlen (strs[APPLET_COMMENT]) > 0) ? + g_strdup (strs[APPLET_COMMENT]) : NULL; + info->icon = (strlen (strs[APPLET_ICON]) > 0) ? + g_strdup (strs[APPLET_ICON]) : NULL; + + return info; +} + +void +panel_applet_info_free (PanelAppletInfo *info) +{ + if (!info) + return; + + g_free (info->id); + g_free (info->name); + g_free (info->comment); + g_free (info->icon); + + g_free (info); +} + +GList * +panel_applet_manager_get_applets (PanelAppletManager *manager) +{ + GError *error = NULL; + GPtrArray *array; + GList *applets = NULL; + gint i; + + g_return_val_if_fail (PANEL_IS_APPLET_MANAGER (manager), NULL); + g_return_val_if_fail (DBUS_IS_G_PROXY (manager->priv->proxy), NULL); + + if (!dbus_g_proxy_call (manager->priv->proxy, "GetApplets", &error, + G_TYPE_INVALID, + dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), + &array, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + + return NULL; + } + + for (i = 0; i < array->len; i++) { + gchar **strs; + PanelAppletInfo *info; + + strs = g_ptr_array_index (array, i); + info = panel_applet_info_new (strs); + applets = g_list_append (applets, info); + + g_strfreev (strs); + } + + g_ptr_array_free (array, TRUE); + + return applets; +} + +PanelAppletInfo * +panel_applet_manager_get_applet_info (PanelAppletManager *manager, + const gchar *applet_id) +{ + PanelAppletInfo *info; + gchar **strs; + GError *error = NULL; + + g_return_val_if_fail (PANEL_IS_APPLET_MANAGER (manager), NULL); + g_return_val_if_fail (DBUS_IS_G_PROXY (manager->priv->proxy), NULL); + g_return_val_if_fail (applet_id != NULL, NULL); + + if (!dbus_g_proxy_call (manager->priv->proxy, "GetAppletInfo", &error, + G_TYPE_STRING, applet_id, + G_TYPE_INVALID, + G_TYPE_STRV, &strs, + G_TYPE_INVALID)) { + g_warning (error->message); + g_clear_error (&error); + + return NULL; + } + + info = panel_applet_info_new (strs); + + return info; +} Index: libpanel-applet/panel-applet-manager.h =================================================================== RCS file: libpanel-applet/panel-applet-manager.h diff -N libpanel-applet/panel-applet-manager.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-manager.h 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,72 @@ +/* + * panel-applet-manager.h: panel applet manager. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#ifndef __PANEL_APPLET_MANAGER_H__ +#define __PANEL_APPLET_MANAGER_H__ + +#include +#include + +G_BEGIN_DECLS + +#define PANEL_TYPE_APPLET_MANAGER (panel_applet_manager_get_type ()) +#define PANEL_APPLET_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_MANAGER, PanelAppletManager)) +#define PANEL_APPLET_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_MANAGER, PanelAppletManagerClass)) +#define PANEL_IS_APPLET_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_MANAGER)) +#define PANEL_IS_APPLET_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_MANAGER)) +#define PANEL_APPLET_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_MANAGER, PanelAppletManagerClass)) + +typedef struct _PanelAppletManager PanelAppletManager; +typedef struct _PanelAppletManagerClass PanelAppletManagerClass; +typedef struct _PanelAppletManagerPrivate PanelAppletManagerPrivate; + +typedef struct { + gchar *id; + gchar *name; + gchar *comment; + gchar *icon; +} PanelAppletInfo; + +struct _PanelAppletManager { + GObject parent; + + PanelAppletManagerPrivate *priv; +}; + +struct _PanelAppletManagerClass { + GObjectClass parent_class; +}; + +GType panel_applet_manager_get_type (void) G_GNUC_CONST; +PanelAppletManager *panel_applet_manager_new (void); + +GList *panel_applet_manager_get_applets (PanelAppletManager *manager); +PanelAppletInfo *panel_applet_manager_get_applet_info (PanelAppletManager *manager, + const gchar *applet_id); + +void panel_applet_info_free (PanelAppletInfo *info); + +G_END_DECLS + +#endif /* __PANEL_APPLET_MANAGER_H__ */ Index: libpanel-applet/panel-applet-marshal.list =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet-marshal.list,v retrieving revision 1.7 diff -u -u -r1.7 panel-applet-marshal.list --- libpanel-applet/panel-applet-marshal.list 4 Feb 2004 15:02:32 -0000 1.7 +++ libpanel-applet/panel-applet-marshal.list 30 Dec 2005 18:06:57 -0000 @@ -3,3 +3,6 @@ VOID:UINT VOID:ENUM BOOLEAN:STRING +VOID:STRING +VOID:BOXED +VOID:VOID Index: libpanel-applet/panel-applet-menu.c =================================================================== RCS file: libpanel-applet/panel-applet-menu.c diff -N libpanel-applet/panel-applet-menu.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-menu.c 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,398 @@ +/* + * panel-applet.menu.c: panel applet popup menu. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#include +#include +#include +#include + +#include "panel-applet-menu.h" +#include "panel-applet-marshal.h" + +/* Container Menu */ +static gboolean panel_applet_menu_container_setup_ui (PanelAppletMenu *menu, + const gchar *IN_xml, + GError **error); +static gboolean panel_applet_menu_container_add_actions (PanelAppletMenu *menu, + const GPtrArray *IN_actions, + GError **error); +static gboolean panel_applet_menu_container_add_toggle_actions (PanelAppletMenu *menu, + const GPtrArray *IN_actions, + GError **error); +static gboolean panel_applet_menu_container_set_property (PanelAppletMenu *menu, + const gchar *IN_action, + const gchar *IN_property, + const GValue *IN_value, + GError **error); + +#include "panel-applet-menu-glue.h" + +static void panel_applet_menu_init (PanelAppletMenu *menu); +static void panel_applet_menu_class_init (PanelAppletMenuClass *klass); +static void panel_applet_menu_finalize (GObject *object); + +struct _PanelAppletMenuPrivate { + GtkUIManager *ui_manager; + GtkActionGroup *applet_group; + GtkActionGroup *container_group; + guint container_ui; +}; + +enum { + ACTIVATE, + LAST_SIGNAL +}; + +enum { + ACTION_NAME, + ACTION_STOCK_ID, + ACTION_LABEL +}; + +#define PANEL_APPLET_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_MENU, PanelAppletMenuPrivate)) + +static GObjectClass *parent_class = NULL; + +static guint panel_applet_menu_signals [LAST_SIGNAL]; + +GType +panel_applet_menu_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (PanelAppletMenuClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) panel_applet_menu_class_init, + NULL, + NULL, + sizeof (PanelAppletMenu), + 0, + (GInstanceInitFunc) panel_applet_menu_init + }; + + type = g_type_register_static (G_TYPE_OBJECT, "PanelAppletMenu", + &info, 0); + } + + return type; +} + +static void +panel_applet_menu_init (PanelAppletMenu *menu) +{ + menu->priv = PANEL_APPLET_MENU_GET_PRIVATE (menu); + + menu->priv->ui_manager = gtk_ui_manager_new (); + + menu->priv->applet_group = gtk_action_group_new ("AppletActions"); + gtk_action_group_set_translation_domain (menu->priv->applet_group, NULL); + gtk_ui_manager_insert_action_group (menu->priv->ui_manager, + menu->priv->applet_group, 0); + + menu->priv->container_group = gtk_action_group_new ("ContainerActions"); + gtk_action_group_set_translation_domain (menu->priv->container_group, NULL); + gtk_ui_manager_insert_action_group (menu->priv->ui_manager, + menu->priv->container_group, 1); + menu->priv->container_ui = 0; +} + +static void +panel_applet_menu_class_init (PanelAppletMenuClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (PanelAppletMenuPrivate)); + + gobject_class->finalize = panel_applet_menu_finalize; + + /* Container menu signal */ + panel_applet_menu_signals [ACTIVATE] = + g_signal_new ("activate", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, + NULL, + panel_applet_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + + dbus_g_object_type_install_info (PANEL_TYPE_APPLET_MENU, + &dbus_glib_panel_applet_container_menu_object_info); +} + +static void +panel_applet_menu_finalize (GObject *object) +{ + PanelAppletMenu *menu = PANEL_APPLET_MENU (object); + + if (menu->priv->ui_manager) { + g_object_unref (menu->priv->ui_manager); + menu->priv->ui_manager = NULL; + } + + if (menu->priv->applet_group) { + g_object_unref (menu->priv->applet_group); + menu->priv->applet_group = NULL; + } + + if (menu->priv->container_group) { + g_object_unref (menu->priv->container_group); + menu->priv->container_group = NULL; + } + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +PanelAppletMenu * +panel_applet_menu_new (void) +{ + PanelAppletMenu *menu; + + menu = PANEL_APPLET_MENU (g_object_new (PANEL_TYPE_APPLET_MENU, + NULL)); + return menu; +} + +/* Applet Menu */ +GtkWidget * +panel_applet_menu_get_popup (PanelAppletMenu *menu) +{ + return gtk_ui_manager_get_widget (menu->priv->ui_manager, + "/AppletPopup"); +} + +void +panel_applet_menu_add_ui_from_string (PanelAppletMenu *menu, + const gchar *xml) +{ + static const gchar *separator = + "\n" + "\n" + ""; + + g_return_if_fail (PANEL_IS_APPLET_MENU (menu)); + g_return_if_fail (xml != NULL); + + if (menu->priv->container_ui > 0) { + gchar *ui; + + ui = gtk_ui_manager_get_ui (menu->priv->ui_manager); + gtk_ui_manager_remove_ui (menu->priv->ui_manager, + menu->priv->container_ui); + gtk_ui_manager_ensure_update (menu->priv->ui_manager); + + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + xml, -1, NULL); + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + separator, -1, NULL); + + menu->priv->container_ui = + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + ui, -1, NULL); + g_free (ui); + } else { + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + xml, -1, NULL); + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + separator, -1, NULL); + } +} + +void +panel_applet_menu_add_ui_from_file (PanelAppletMenu *menu, + const gchar *opt_datadir, + const gchar *file, + const gchar *opt_ui_dirname) +{ + gchar *ui_dirname = NULL; + gchar *filename; + gchar *xml = NULL; + GError *error = NULL; + + g_return_if_fail (PANEL_IS_APPLET_MENU (menu)); + + if (!opt_datadir) + opt_datadir = PANEL_APPLET_DATADIR; + + if (!opt_ui_dirname) + ui_dirname = g_build_filename ("gnome-2.0", "ui", NULL); + + filename = g_build_filename (opt_datadir, ui_dirname, file, NULL); + + if (g_file_get_contents (filename, &xml, NULL, &error)) { + panel_applet_menu_add_ui_from_string (menu, xml); + } else { + g_warning ("%s", error->message); + g_clear_error (&error); + } + + g_free (filename); + g_free (ui_dirname); +} + +void +panel_applet_menu_add_actions (PanelAppletMenu *menu, + const GtkActionEntry *actions, + guint n_entries, + gpointer user_data) +{ + g_return_if_fail (actions != NULL); + + gtk_action_group_add_actions (menu->priv->applet_group, + actions, n_entries, user_data); +} + +void +panel_applet_menu_add_toggle_actions (PanelAppletMenu *menu, + const GtkToggleActionEntry *actions, + guint n_entries, + gpointer user_data) +{ + g_return_if_fail (actions != NULL); + + gtk_action_group_add_toggle_actions (menu->priv->applet_group, + actions, n_entries, user_data); +} + +GtkAction * +panel_applet_menu_get_action (PanelAppletMenu *menu, + const gchar *action) +{ + + g_return_val_if_fail (action != NULL, NULL); + + return gtk_action_group_get_action (menu->priv->applet_group, action); +} + + +/* Container Menu */ +static void +panel_applet_menu_container_action_activate (GtkAction *action, gpointer gdata) +{ + PanelAppletMenu *menu = PANEL_APPLET_MENU (gdata); + + g_signal_emit (menu, panel_applet_menu_signals[ACTIVATE], + 0, gtk_action_get_name (action)); +} + +static gboolean +panel_applet_menu_container_setup_ui (PanelAppletMenu *menu, + const gchar *IN_xml, + GError **error) +{ + menu->priv->container_ui = + gtk_ui_manager_add_ui_from_string (menu->priv->ui_manager, + IN_xml, -1, NULL); + return TRUE; +} + +static gboolean +panel_applet_menu_container_add_actions (PanelAppletMenu *menu, + const GPtrArray *IN_actions, + GError **error) +{ + GtkActionEntry *entries; + gint i; + + entries = g_new0 (GtkActionEntry, IN_actions->len); + + for (i = 0; i < IN_actions->len; i++) { + gchar **strs; + + strs = g_ptr_array_index (IN_actions, i); + + entries[i].name = strs[ACTION_NAME]; + entries[i].stock_id = strs[ACTION_STOCK_ID]; + entries[i].label = strs[ACTION_LABEL]; + entries[i].callback = G_CALLBACK (panel_applet_menu_container_action_activate); + } + + gtk_action_group_add_actions (menu->priv->container_group, + entries, IN_actions->len, + (gpointer) menu); + + return TRUE; +} + +static gboolean +panel_applet_menu_container_add_toggle_actions (PanelAppletMenu *menu, + const GPtrArray *IN_actions, + GError **error) +{ + GtkToggleActionEntry *entries; + gint i; + + entries = g_new0 (GtkToggleActionEntry, IN_actions->len); + + for (i = 0; i < IN_actions->len; i++) { + gchar **strs; + + strs = g_ptr_array_index (IN_actions, i); + + entries[i].name = strs[ACTION_NAME]; + entries[i].stock_id = strs[ACTION_STOCK_ID]; + entries[i].label = strs[ACTION_LABEL]; + entries[i].callback = G_CALLBACK (panel_applet_menu_container_action_activate); + } + + gtk_action_group_add_toggle_actions (menu->priv->container_group, + entries, IN_actions->len, + (gpointer) menu); + + return TRUE; +} + +static gboolean +panel_applet_menu_container_set_property (PanelAppletMenu *menu, + const gchar *IN_action, + const gchar *IN_property, + const GValue *IN_value, + GError **error) +{ + GtkAction *action; + + action = gtk_action_group_get_action (menu->priv->container_group, + IN_action); + if (action) { + /* active is not a GtkToggleAction property */ + if ((g_ascii_strcasecmp (IN_property, "active") == 0) && + GTK_IS_TOGGLE_ACTION (action)) { + gboolean active = g_value_get_boolean (IN_value); + + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + active); + } else { + g_object_set_property (G_OBJECT (action), IN_property, IN_value); + } + } + + return TRUE; +} Index: libpanel-applet/panel-applet-menu.h =================================================================== RCS file: libpanel-applet/panel-applet-menu.h diff -N libpanel-applet/panel-applet-menu.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-menu.h 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,77 @@ +/* + * panel-applet.menu.h: panel applet popup menu. + * + * Copyright (C) 2005 Carlos Garcia Campos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Carlos Garcia Campos + */ + +#ifndef __PANEL_APPLET_MENU_H__ +#define __PANEL_APPLET_MENU_H__ + +#include + +G_BEGIN_DECLS + +#define PANEL_TYPE_APPLET_MENU (panel_applet_menu_get_type ()) +#define PANEL_APPLET_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_MENU, PanelAppletMenu)) +#define PANEL_APPLET_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_MENU, PanelAppletMenuClass)) +#define PANEL_IS_APPLET_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_MENU)) +#define PANEL_IS_APPLET_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_MENU)) +#define PANEL_APPLET_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_MENU, PanelAppletMenuClass)) + +typedef struct _PanelAppletMenu PanelAppletMenu; +typedef struct _PanelAppletMenuClass PanelAppletMenuClass; +typedef struct _PanelAppletMenuPrivate PanelAppletMenuPrivate; + +struct _PanelAppletMenu { + GObject parent; + + PanelAppletMenuPrivate *priv; +}; + +struct _PanelAppletMenuClass { + GObjectClass parent_class; +}; + +GType panel_applet_menu_get_type (void) G_GNUC_CONST; +PanelAppletMenu *panel_applet_menu_new (void); + +/* Applet Menu */ +GtkWidget *panel_applet_menu_get_popup (PanelAppletMenu *menu); +void panel_applet_menu_add_ui_from_string (PanelAppletMenu *menu, + const gchar *xml); +void panel_applet_menu_add_ui_from_file (PanelAppletMenu *menu, + const gchar *opt_datadir, + const gchar *file, + const gchar *opt_ui_dirname); +void panel_applet_menu_add_actions (PanelAppletMenu *menu, + const GtkActionEntry *actions, + guint n_entries, + gpointer user_data); +void panel_applet_menu_add_toggle_actions (PanelAppletMenu *menu, + const GtkToggleActionEntry *actions, + guint n_entries, + gpointer user_data); +GtkAction *panel_applet_menu_get_action (PanelAppletMenu *menu, + const gchar *action); + +G_END_DECLS + +#endif /* __PANEL_APPLET_MENU_H__ */ Index: libpanel-applet/panel-applet-menu.xml =================================================================== RCS file: libpanel-applet/panel-applet-menu.xml diff -N libpanel-applet/panel-applet-menu.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet-menu.xml 30 Dec 2005 18:06:57 -0000 @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: libpanel-applet/panel-applet.c =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet.c,v retrieving revision 1.100 diff -u -u -r1.100 panel-applet.c --- libpanel-applet/panel-applet.c 29 Dec 2005 18:45:27 -0000 1.100 +++ libpanel-applet/panel-applet.c 30 Dec 2005 18:06:58 -0000 @@ -34,53 +34,62 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include #include "panel-applet.h" -#include "panel-applet-private.h" -#include "panel-applet-shell.h" #include "panel-applet-marshal.h" #include "panel-applet-enums.h" +static gboolean panel_applet_get_xid (PanelApplet *applet, + gint IN_screen, + guint32 *OUT_xid, + GError **error); +static gboolean panel_applet_popup_menu (PanelApplet *applet, + guint IN_button, + guint32 IN_time, + GError **error); +static gboolean panel_applet_notify_add (PanelApplet *applet, + const gchar *IN_property, + GError **error); + +#include "panel-applet-glue.h" + #define PANEL_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET, PanelAppletPrivate)) struct _PanelAppletPrivate { - PanelAppletShell *shell; - BonoboControl *control; - BonoboPropertyBag *prop_sack; - BonoboItemHandler *item_handler; - GConfClient *client; - - char *iid; - GClosure *closure; - gboolean bound; - char *prefs_key; - - PanelAppletFlags flags; - PanelAppletOrient orient; - guint size; - char *background; - GtkWidget *background_widget; - - int previous_width; - int previous_height; + GtkWidget *plug; + GtkWidget *applet; + guint32 xid; + PanelAppletMenu *menu; + GConfClient *client; + + gchar *id; + GClosure *closure; + gboolean embedded; + gchar *prefs_key; + + PanelAppletFlags flags; + PanelAppletOrient orient; + guint size; + gchar *background; + GtkWidget *background_widget; + + int previous_width; + int previous_height; + GArray *size_hints; - int *size_hints; - int size_hints_len; + gboolean moving_focus_out; - gboolean moving_focus_out; + gboolean locked_down; - gboolean locked_down; + GHashTable *notifies; }; static GObjectClass *parent_class; @@ -91,19 +100,17 @@ CHANGE_BACKGROUND, MOVE_FOCUS_OUT_OF_APPLET, SAVE_YOURSELF, + PROPERTY_CHANGED, LAST_SIGNAL }; static guint panel_applet_signals [LAST_SIGNAL]; -#define PROPERTY_ORIENT "panel-applet-orient" -#define PROPERTY_SIZE "panel-applet-size" -#define PROPERTY_BACKGROUND "panel-applet-background" -#define PROPERTY_FLAGS "panel-applet-flags" -#define PROPERTY_SIZE_HINTS "panel-applet-size-hints" -#define PROPERTY_LOCKED_DOWN "panel-applet-locked-down" - enum { + PROPERTY_0, + PROPERTY_ID, + PROPERTY_CLOSURE, + PROPERTY_PREFS_KEY, PROPERTY_ORIENT_IDX, PROPERTY_SIZE_IDX, PROPERTY_BACKGROUND_IDX, @@ -248,6 +255,11 @@ applet->priv->prefs_key, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); + + if (g_hash_table_lookup (applet->priv->notifies, "prefs-key")) { + g_signal_emit (applet, panel_applet_signals [PROPERTY_CHANGED], + 0, "prefs-key"); + } } } @@ -265,45 +277,62 @@ { g_return_if_fail (PANEL_IS_APPLET (applet)); - if (applet->priv->prop_sack != NULL) - bonobo_pbclient_set_short (BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_FLAGS, flags, NULL); - else + if (applet->priv->flags != flags) { applet->priv->flags = flags; + + if (g_hash_table_lookup (applet->priv->notifies, "flags")) { + g_signal_emit (applet, panel_applet_signals [PROPERTY_CHANGED], + 0, "flags"); + } + } } void -panel_applet_set_size_hints (PanelApplet *applet, - const int *size_hints, - int n_elements, - int base_size) -{ - CORBA_sequence_CORBA_long *seq; - CORBA_Environment env; - CORBA_any any; - int i; - - CORBA_exception_init (&env); - - seq = CORBA_sequence_CORBA_long__alloc (); - seq->_length = seq->_maximum = n_elements; - seq->_release = CORBA_TRUE; - seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length); - - for (i = 0; i < n_elements; i++) - seq->_buffer [i] = size_hints [i] + base_size; - - any._type = TC_CORBA_sequence_CORBA_long; - any._release = CORBA_FALSE; - any._value = seq; - - Bonobo_PropertyBag_setValue (BONOBO_OBJREF (applet->priv->prop_sack), - PROPERTY_SIZE_HINTS, - &any, - &env); +panel_applet_set_size_hints (PanelApplet *applet, + const int *size_hints, + int n_elements, + int base_size) +{ + GArray *shints; + gint i, val; + gboolean notify = FALSE; + + g_return_if_fail (PANEL_IS_APPLET (applet)); + + if (!applet->priv->size_hints) + notify = TRUE; - CORBA_free (seq); + if (!notify && (n_elements != applet->priv->size_hints->len)) + notify = TRUE; - CORBA_exception_free (&env); + shints = g_array_sized_new (FALSE, FALSE, sizeof (gint), + n_elements); + + for (i = 0; i < n_elements; i++) { + val = size_hints[i] + base_size; + g_array_append_val (shints, val); + + if (!notify && + (val != g_array_index (applet->priv->size_hints, gint, i))) + notify = TRUE; + } + + if (applet->priv->size_hints) + g_array_free (applet->priv->size_hints, TRUE); + applet->priv->size_hints = shints; + + if (notify && g_hash_table_lookup (applet->priv->notifies, "size-hints")) { + g_signal_emit (applet, panel_applet_signals [PROPERTY_CHANGED], + 0, "size-hints"); + } +} + +void +panel_applet_set_size (PanelApplet *applet, guint size) +{ + g_return_if_fail (PANEL_IS_APPLET (applet)); + + applet->priv->size = size; } guint @@ -465,71 +494,13 @@ &xev); } -void -panel_applet_setup_menu (PanelApplet *applet, - const gchar *xml, - const BonoboUIVerb *verb_list, - gpointer user_data) -{ - BonoboUIComponent *popup_component; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (xml != NULL && verb_list != NULL); - - popup_component = panel_applet_get_popup_component (applet); - - bonobo_ui_component_set (popup_component, "/", "", NULL); - - bonobo_ui_component_set_translate (popup_component, "/popups", xml, NULL); - - bonobo_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data); -} - -void -panel_applet_setup_menu_from_file (PanelApplet *applet, - const gchar *opt_datadir, - const gchar *file, - const gchar *opt_app_name, - const BonoboUIVerb *verb_list, - gpointer user_data) -{ - BonoboUIComponent *popup_component; - gchar *app_name = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (file != NULL && verb_list != NULL); - - if (!opt_datadir) - opt_datadir = PANEL_APPLET_DATADIR; - - if (!opt_app_name) - opt_app_name = app_name = g_strdup_printf ("%lu", - (unsigned long) getpid ()); - - popup_component = panel_applet_get_popup_component (applet); - - bonobo_ui_util_set_ui (popup_component, opt_datadir, file, opt_app_name, NULL); - - bonobo_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data); - - if (app_name) - g_free (app_name); -} - -BonoboControl * -panel_applet_get_control (PanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - return applet->priv->control; -} - -BonoboUIComponent * -panel_applet_get_popup_component (PanelApplet *applet) +/* Setup Menu */ +PanelAppletMenu * +panel_applet_get_menu (PanelApplet *applet) { g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - return bonobo_control_get_popup_ui_component (applet->priv->control); + return applet->priv->menu; } static void @@ -543,20 +514,26 @@ g_object_unref (applet->priv->client); applet->priv->client = NULL; - if (applet->priv->prop_sack) - bonobo_object_unref ( - BONOBO_OBJECT (applet->priv->prop_sack)); - applet->priv->prop_sack = NULL; - - g_free (applet->priv->size_hints); + if (applet->priv->size_hints) + g_array_free (applet->priv->size_hints, TRUE); + applet->priv->size_hints = NULL; + g_free (applet->priv->prefs_key); g_free (applet->priv->background); - g_free (applet->priv->iid); - + g_free (applet->priv->id); + + if (applet->priv->notifies) + g_hash_table_destroy (applet->priv->notifies); + applet->priv->notifies = NULL; + if (applet->priv->closure) g_closure_unref (applet->priv->closure); applet->priv->closure = NULL; + if (applet->priv->menu) + g_object_unref (applet->priv->menu); + applet->priv->menu = NULL; + parent_class->finalize (object); } @@ -600,11 +577,11 @@ int pointer_x; int pointer_y; - g_return_if_fail (PANEL_IS_APPLET (widget)); + g_assert (PANEL_IS_APPLET (widget)); applet = PANEL_APPLET (widget); - screen = gtk_widget_get_screen (widget); + screen = gtk_window_get_screen (GTK_WINDOW (applet->priv->plug)); gtk_widget_size_request (GTK_WIDGET (menu), &requisition); @@ -635,7 +612,6 @@ menu_x -= requisition.width; else menu_x += widget->allocation.width; - } *x = menu_x; @@ -659,6 +635,80 @@ return !container_has_focusable_child (GTK_CONTAINER (widget)); } +/* Taken from libbonoboui */ +static gboolean +panel_applet_forward_button_events (GtkWidget *widget, + GdkEventButton *event) +{ + XEvent xevent; + + if (!GTK_WIDGET_TOPLEVEL (widget)) + return FALSE; + + if (event->type == GDK_BUTTON_PRESS) { + xevent.xbutton.type = ButtonPress; + + /* X does an automatic pointer grab on button press + * if we have both button press and release events + * selected. + * We don't want to hog the pointer on our parent. + */ + gdk_display_pointer_ungrab + (gtk_widget_get_display (widget), + GDK_CURRENT_TIME); + } else { + xevent.xbutton.type = ButtonRelease; + } + + xevent.xbutton.display = GDK_WINDOW_XDISPLAY (widget->window); + xevent.xbutton.window = GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window); + xevent.xbutton.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window + (gdk_drawable_get_screen (widget->window))); + /* + * FIXME: the following might cause + * big problems for non-GTK apps + */ + xevent.xbutton.x = 0; + xevent.xbutton.y = 0; + xevent.xbutton.x_root = 0; + xevent.xbutton.y_root = 0; + xevent.xbutton.state = event->state; + xevent.xbutton.button = event->button; + xevent.xbutton.same_screen = TRUE; /* FIXME ? */ + + gdk_error_trap_push (); + + XSendEvent (GDK_WINDOW_XDISPLAY (widget->window), + GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window), + False, NoEventMask, &xevent); + + gdk_flush (); + gdk_error_trap_pop (); + + return TRUE; +} + +static gboolean +panel_applet_popup_menu_full (PanelApplet *applet, + GtkMenuPositionFunc position_func, + gpointer user_data, + guint button, + guint32 time) +{ + GtkWidget *popup; + + popup = panel_applet_menu_get_popup (applet->priv->menu); + if (popup) { + gtk_menu_popup (GTK_MENU (popup), NULL, NULL, + position_func, + user_data, + button, time); + return TRUE; + } + + return FALSE; +} + static gboolean panel_applet_button_press (GtkWidget *widget, GdkEventButton *event) @@ -672,37 +722,30 @@ } } - if (event->button == 1) - return TRUE; - else if (event->button == 3) { - bonobo_control_do_popup_full ( - applet->priv->control, - NULL, NULL, - (GtkMenuPositionFunc) panel_applet_position_menu, - applet, - event->button, - event->time); + if (event->button == 1) { + return panel_applet_forward_button_events (applet->priv->plug, event); + } else if (event->button == 3) { + if (!panel_applet_popup_menu_full (applet, + (GtkMenuPositionFunc) panel_applet_position_menu, + applet, + event->button, + event->time)) { + return panel_applet_forward_button_events (applet->priv->plug, event); + } + return TRUE; } - return FALSE; -} - -gboolean -_panel_applet_popup_menu (PanelApplet *applet, - guint button, - guint32 time) -{ - bonobo_control_do_popup_full (applet->priv->control, NULL, NULL, - (GtkMenuPositionFunc) panel_applet_position_menu, - applet, button, time); - return TRUE; + return panel_applet_forward_button_events (applet->priv->plug, event); } static gboolean -panel_applet_popup_menu (PanelApplet *applet) +panel_applet_button_release (GtkWidget *widget, + GdkEventButton *event) { - return _panel_applet_popup_menu (applet, 3, GDK_CURRENT_TIME); + PanelApplet *applet = PANEL_APPLET (widget); + + return panel_applet_forward_button_events (applet->priv->plug, event); } static void @@ -832,7 +875,8 @@ GtkWidget *previous_focus_child; PanelApplet *applet; - g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); + if (!PANEL_IS_APPLET (widget)) + return FALSE; applet = PANEL_APPLET (widget); if (applet->priv->moving_focus_out) { @@ -901,10 +945,10 @@ char **elements; char *tmp; - g_return_val_if_fail (str != NULL, FALSE); - g_return_val_if_fail (xid != NULL, FALSE); - g_return_val_if_fail (x != NULL, FALSE); - g_return_val_if_fail (y != NULL, FALSE); + g_assert (str != NULL); + g_assert (xid != NULL); + g_assert (x != NULL); + g_assert (y != NULL); elements = g_strsplit (str, ",", -1); @@ -949,7 +993,8 @@ int width; int height; - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); + if (!PANEL_IS_APPLET (applet)) + return NULL; if (!GTK_WIDGET_REALIZED (applet)) return NULL; @@ -1066,47 +1111,69 @@ } static void -panel_applet_get_prop (BonoboPropertyBag *sack, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) +panel_applet_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PanelApplet *applet = PANEL_APPLET (user_data); + PanelApplet *applet = PANEL_APPLET (object); - switch (arg_id) { + switch (prop_id) { + case PROPERTY_ID: + g_value_set_string (value, applet->priv->id); + break; + case PROPERTY_CLOSURE: + g_value_set_pointer (value, applet->priv->closure); + break; + case PROPERTY_PREFS_KEY: + g_value_set_string (value, applet->priv->prefs_key); + break; case PROPERTY_ORIENT_IDX: - BONOBO_ARG_SET_SHORT (arg, applet->priv->orient); + g_value_set_uint (value, applet->priv->orient); break; case PROPERTY_SIZE_IDX: - BONOBO_ARG_SET_SHORT (arg, applet->priv->size); + g_value_set_uint (value, applet->priv->size); break; case PROPERTY_BACKGROUND_IDX: - BONOBO_ARG_SET_STRING (arg, applet->priv->background); + g_value_set_string (value, applet->priv->background); break; case PROPERTY_FLAGS_IDX: - BONOBO_ARG_SET_SHORT (arg, applet->priv->flags); + g_value_set_uint (value, applet->priv->flags); break; case PROPERTY_SIZE_HINTS_IDX: { - CORBA_sequence_CORBA_long *seq; - int i; + GValueArray *varray; + gint i; + + if (!applet->priv->size_hints) { + GValue val = {0, }; - seq = arg->_value; + g_value_init (&val, G_TYPE_INT); + g_value_set_int (&val, -1); + varray = g_value_array_new (1); + g_value_array_append (varray, &val); + g_value_unset (&val); + } else { + varray = g_value_array_new (applet->priv->size_hints->len); + + for (i = 0; i < applet->priv->size_hints->len; i++) { + GValue val = {0, }; + + g_value_init (&val, G_TYPE_INT); + g_value_set_int (&val, g_array_index (applet->priv->size_hints, + gint, i)); + g_value_array_append (varray, &val); + g_value_unset (&val); + } + } - seq->_length = seq->_maximum = applet->priv->size_hints_len; - seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length); - seq->_release = CORBA_TRUE; - - for (i = 0; i < applet->priv->size_hints_len; i++) - seq->_buffer [i] = applet->priv->size_hints [i]; + g_value_take_boxed (value, varray); } break; case PROPERTY_LOCKED_DOWN_IDX: - BONOBO_ARG_SET_BOOLEAN (arg, applet->priv->locked_down); + g_value_set_boolean (value, applet->priv->locked_down); break; default: - g_assert_not_reached (); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } @@ -1180,25 +1247,48 @@ g_assert_not_reached (); break; } + + if (g_hash_table_lookup (applet->priv->notifies, "background")) { + g_signal_emit (applet, panel_applet_signals [PROPERTY_CHANGED], + 0, "background"); + } } static void -panel_applet_set_prop (BonoboPropertyBag *sack, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) +panel_applet_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PanelApplet *applet = PANEL_APPLET (user_data); - - switch (arg_id) { + PanelApplet *applet = PANEL_APPLET (object); + gboolean notify = FALSE; + + switch (prop_id) { + case PROPERTY_ID: + if (!applet->priv->id) { + applet->priv->id = g_value_dup_string (value); + } + break; + case PROPERTY_CLOSURE: + if (!applet->priv->closure) { + applet->priv->closure = g_value_get_pointer (value); + g_closure_set_marshal (applet->priv->closure, + panel_applet_marshal_BOOLEAN__STRING); + } + + break; + case PROPERTY_PREFS_KEY: + panel_applet_set_preferences_key (applet, + g_value_get_string (value)); + break; case PROPERTY_ORIENT_IDX: { PanelAppletOrient orient; - orient = BONOBO_ARG_GET_SHORT (arg); + orient = g_value_get_uint (value); if (applet->priv->orient != orient) { applet->priv->orient = orient; + notify = TRUE; g_signal_emit (G_OBJECT (applet), panel_applet_signals [CHANGE_ORIENT], @@ -1209,10 +1299,11 @@ case PROPERTY_SIZE_IDX: { guint size; - size = BONOBO_ARG_GET_SHORT (arg); + size = g_value_get_uint (value); if (applet->priv->size != size) { applet->priv->size = size; + notify = TRUE; g_signal_emit (G_OBJECT (applet), panel_applet_signals [CHANGE_SIZE], @@ -1224,92 +1315,74 @@ if (applet->priv->background) g_free (applet->priv->background); - applet->priv->background = g_strdup (BONOBO_ARG_GET_STRING (arg)); + applet->priv->background = g_value_dup_string (value); panel_applet_handle_background (applet); break; - case PROPERTY_FLAGS_IDX: - applet->priv->flags = BONOBO_ARG_GET_SHORT (arg); + case PROPERTY_FLAGS_IDX: { + guint flags; + + flags = g_value_get_uint (value); + + if (applet->priv->flags != flags) { + applet->priv->flags = flags; + notify = TRUE; + } + } break; case PROPERTY_SIZE_HINTS_IDX: { - CORBA_sequence_CORBA_long *seq = arg->_value; - int i; - - applet->priv->size_hints = g_realloc (applet->priv->size_hints, - seq->_length * sizeof (int)); - for (i = 0; i < seq->_length; i++) - applet->priv->size_hints [i] = seq->_buffer [i]; + GValueArray *varray; + GArray *size_hints; + gint i, val; - applet->priv->size_hints_len = seq->_length;; + if (!applet->priv->size_hints) + notify = TRUE; + + varray = g_value_get_boxed (value); + + if (varray) { + if (!notify && + (varray->n_values != applet->priv->size_hints->len)) + notify = TRUE; + + size_hints = g_array_sized_new (FALSE, FALSE, + sizeof (gint), + varray->n_values); + + for (i = 0; i < varray->n_values; i++) { + val = g_value_get_int (g_value_array_get_nth (varray, i)); + g_array_append_val (size_hints, val); + + if (!notify && + (val != g_array_index (applet->priv->size_hints, gint, i))) + notify = TRUE; + } + + if (applet->priv->size_hints) + g_array_free (applet->priv->size_hints, TRUE); + applet->priv->size_hints = size_hints; + } } break; - case PROPERTY_LOCKED_DOWN_IDX: - applet->priv->locked_down = BONOBO_ARG_GET_BOOLEAN (arg); + case PROPERTY_LOCKED_DOWN_IDX: { + gboolean locked_down; + + locked_down = g_value_get_boolean (value); + + if (applet->priv->locked_down != locked_down) { + applet->priv->locked_down = locked_down; + notify = TRUE; + } + } break; default: - g_assert_not_reached (); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } -} - -static BonoboPropertyBag * -panel_applet_property_bag (PanelApplet *applet) -{ - BonoboPropertyBag *sack; - - sack = bonobo_property_bag_new (panel_applet_get_prop, - panel_applet_set_prop, - applet); - - bonobo_property_bag_add (sack, - PROPERTY_ORIENT, - PROPERTY_ORIENT_IDX, - BONOBO_ARG_SHORT, - NULL, - _("The Applet's containing Panel's orientation"), - Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (sack, - PROPERTY_SIZE, - PROPERTY_SIZE_IDX, - BONOBO_ARG_SHORT, - NULL, - _("The Applet's containing Panel's size in pixels"), - Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (sack, - PROPERTY_BACKGROUND, - PROPERTY_BACKGROUND_IDX, - BONOBO_ARG_STRING, - NULL, - _("The Applet's containing Panel's background color or pixmap"), - Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (sack, - PROPERTY_FLAGS, - PROPERTY_FLAGS_IDX, - BONOBO_ARG_SHORT, - NULL, - _("The Applet's flags"), - Bonobo_PROPERTY_READABLE); - - bonobo_property_bag_add (sack, - PROPERTY_SIZE_HINTS, - PROPERTY_SIZE_HINTS_IDX, - TC_CORBA_sequence_CORBA_long, - NULL, - _("Ranges that hint what sizes are acceptable for the applet"), - Bonobo_PROPERTY_READABLE); - - bonobo_property_bag_add (sack, - PROPERTY_LOCKED_DOWN, - PROPERTY_LOCKED_DOWN_IDX, - BONOBO_ARG_BOOLEAN, - NULL, - _("The Applet's containing Panel is locked down"), - Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE); - return sack; + if (notify && g_hash_table_lookup (applet->priv->notifies, pspec->name)) { + g_signal_emit (applet, panel_applet_signals [PROPERTY_CHANGED], + 0, pspec->name); + } } static void @@ -1322,134 +1395,55 @@ } static void -panel_applet_control_bound (BonoboControl *control, - PanelApplet *applet) +panel_applet_embedded (PanelApplet *applet, + gpointer user_data) { + GValue value = {0, }; + GArray *params; + gint i; gboolean ret; - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (applet->priv->iid != NULL && - applet->priv->closure != NULL); + g_assert (PANEL_IS_APPLET (applet)); + g_assert (applet->priv->id != NULL && + applet->priv->closure != NULL); - if (applet->priv->bound) + if (applet->priv->embedded) return; - bonobo_closure_invoke (applet->priv->closure, - G_TYPE_BOOLEAN, &ret, - PANEL_TYPE_APPLET, applet, - G_TYPE_STRING, applet->priv->iid, - NULL); + params = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 2); + value.g_type = 0; + g_value_init (&value, G_TYPE_OBJECT); + g_value_set_object (&value, G_OBJECT (applet)); + g_array_append_val (params, value); + + value.g_type = 0; + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, applet->priv->id); + g_array_append_val (params, value); + + value.g_type = 0; + g_value_init (&value, G_TYPE_BOOLEAN); + + g_closure_invoke (applet->priv->closure, + &value, params->len, + (GValue *) params->data, + NULL); + + for (i = 0; i < params->len; i++) + g_value_unset (&g_array_index (params, GValue, i)); - if (!ret) { /* FIXME */ - g_warning ("need to free the control here"); + g_array_free (params, TRUE); - return; - } + ret = g_value_get_boolean (&value); + g_value_unset (&value); - applet->priv->bound = TRUE; -} - -static Bonobo_Unknown -panel_applet_item_handler_get_object (BonoboItemHandler *handler, - const char *item_name, - gboolean only_if_exists, - gpointer user_data, - CORBA_Environment *ev) -{ - PanelApplet *applet = user_data; - GSList *options; - GSList *l; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), CORBA_OBJECT_NIL); - - options = bonobo_item_option_parse (item_name); - - for (l = options; l; l = l->next) { - BonoboItemOption *option = l->data; - - if (!option->value || !option->value [0]) - continue; - - if (!strcmp (option->key, "prefs_key") && !applet->priv->prefs_key) - panel_applet_set_preferences_key (applet, option->value); - - else if (!strcmp (option->key, "background")) - bonobo_pbclient_set_string (BONOBO_OBJREF (applet->priv->prop_sack), - PROPERTY_BACKGROUND, option->value, NULL); - - else if (!strcmp (option->key, "orient")) { - if (!strcmp (option->value, "up")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - PANEL_APPLET_ORIENT_UP, NULL); - - else if (!strcmp (option->value, "down")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - PANEL_APPLET_ORIENT_DOWN, NULL); - - else if (!strcmp (option->value, "left")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - PANEL_APPLET_ORIENT_LEFT, NULL); - - else if (!strcmp (option->value, "right")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - PANEL_APPLET_ORIENT_RIGHT, NULL); - - } else if (!strcmp (option->key, "size")) { - if (!strcmp (option->value, "xx-small")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_XX_SMALL, NULL); - - else if (!strcmp (option->value, "x-small")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_X_SMALL, NULL); - - else if (!strcmp (option->value, "small")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_SMALL, NULL); - - else if (!strcmp (option->value, "medium")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_MEDIUM, NULL); - - else if (!strcmp (option->value, "large")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_LARGE, NULL); - - else if (!strcmp (option->value, "x-large")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_X_LARGE, NULL); - - else if (!strcmp (option->value, "xx-large")) - bonobo_pbclient_set_short ( - BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - GNOME_Vertigo_PANEL_XX_LARGE, NULL); - } else if (!strcmp (option->key, "locked_down")) { - gboolean val = FALSE; - if (option->value[0] == 'T' || - option->value[0] == 't' || - option->value[0] == 'Y' || - option->value[0] == 'y' || - atoi (option->value) != 0) - val = TRUE; - bonobo_pbclient_set_boolean (BONOBO_OBJREF (applet->priv->prop_sack), - PROPERTY_LOCKED_DOWN, val, NULL); - } + if (!ret) { + /* FIXME: */ + return; } - bonobo_item_options_free (options); - - return bonobo_object_dup_ref (BONOBO_OBJREF (applet->priv->control), ev); + applet->priv->embedded = TRUE; } static void @@ -1492,16 +1486,91 @@ klass->move_focus_out_of_applet = panel_applet_move_focus_out_of_applet; widget_class->button_press_event = panel_applet_button_press; + widget_class->button_release_event = panel_applet_button_release; widget_class->size_request = panel_applet_size_request; widget_class->size_allocate = panel_applet_size_allocate; widget_class->expose_event = panel_applet_expose; widget_class->focus = panel_applet_focus; widget_class->realize = panel_applet_realize; + gobject_class->set_property = panel_applet_set_property; + gobject_class->get_property = panel_applet_get_property; gobject_class->finalize = panel_applet_finalize; g_type_class_add_private (klass, sizeof (PanelAppletPrivate)); + g_object_class_install_property (gobject_class, + PROPERTY_ID, + g_param_spec_string ("id", + "ID", + "The Applet identifier", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_CLOSURE, + g_param_spec_pointer ("closure", + "GClocure", + "The Applet closure", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_PREFS_KEY, + g_param_spec_string ("prefs-key", + "PrefsKey", + "The Applet gconf preferences key", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_ORIENT_IDX, + g_param_spec_uint ("orient", + "Orient", + "The Applet's containing Panel's orientation", + PANEL_APPLET_ORIENT_UP, + PANEL_APPLET_ORIENT_LEFT, + PANEL_APPLET_ORIENT_UP, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_SIZE_IDX, + g_param_spec_uint ("size", + "Size", + "The Applet's containing Panel's size in pixels", + 0, + G_MAXUINT, + 0, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_SIZE_HINTS_IDX, + g_param_spec_value_array ("size-hints", + "SizeHints", + "Ranges that hint what sizes are acceptable for the applet", + g_param_spec_int ("hints", NULL, NULL, + 0, G_MAXINT, 0, + G_PARAM_READWRITE), + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_BACKGROUND_IDX, + g_param_spec_string ("background", + "Background", + "The Applet's containing Panel's background color or pixmap", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_FLAGS_IDX, + g_param_spec_uint ("flags", + "Flags", + "The Applet's flags", + PANEL_APPLET_FLAGS_NONE, + PANEL_APPLET_HAS_HANDLE, + PANEL_APPLET_FLAGS_NONE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROPERTY_LOCKED_DOWN_IDX, + g_param_spec_boolean ("locked-down", + "Locked Down", + "The Applet's containing Panel is locked down", + FALSE, + G_PARAM_READWRITE)); + + panel_applet_signals [CHANGE_ORIENT] = g_signal_new ("change_orient", G_TYPE_FROM_CLASS (klass), @@ -1551,6 +1620,21 @@ G_TYPE_NONE, 1, GTK_TYPE_DIRECTION_TYPE); + + panel_applet_signals [PROPERTY_CHANGED] = + g_signal_new ("property_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, + NULL, + panel_applet_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + + dbus_g_object_type_install_info (PANEL_TYPE_APPLET, + &dbus_glib_panel_applet_object_info); binding_set = gtk_binding_set_by_class (object_class); add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); @@ -1565,17 +1649,38 @@ { applet->priv = PANEL_APPLET_GET_PRIVATE (applet); + applet->priv->plug = gtk_plug_new (0); + g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded", + G_CALLBACK (panel_applet_embedded), + applet); + + applet->priv->menu = panel_applet_menu_new (); + applet->priv->applet = NULL; + applet->priv->xid = 0; + applet->priv->client = gconf_client_get_default (); - applet->priv->bound = FALSE; - applet->priv->flags = PANEL_APPLET_FLAGS_NONE; + applet->priv->embedded = FALSE; + applet->priv->flags = PANEL_APPLET_FLAGS_NONE; applet->priv->orient = PANEL_APPLET_ORIENT_UP; - applet->priv->size = GNOME_Vertigo_PANEL_MEDIUM; + applet->priv->size = 24; + applet->priv->size_hints = NULL; + + applet->priv->notifies = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, NULL); applet->priv->moving_focus_out = FALSE; gtk_widget_set_events (GTK_WIDGET (applet), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); + + gtk_container_add (GTK_CONTAINER (applet->priv->plug), GTK_WIDGET (applet)); + gtk_widget_show (applet->priv->plug); + + if (GTK_WIDGET_REALIZED (applet->priv->plug)) + applet->priv->xid = GDK_WINDOW_XID (applet->priv->plug->window); + else + applet->priv->xid = 0; } GType @@ -1604,40 +1709,6 @@ return type; } -static void -panel_applet_setup (PanelApplet *applet) -{ - PanelAppletPrivate *priv; - - priv = applet->priv; - - priv->control = bonobo_control_new (GTK_WIDGET (applet)); - - g_signal_connect (priv->control, "set_frame", - G_CALLBACK (panel_applet_control_bound), - applet); - - priv->prop_sack = panel_applet_property_bag (applet); - - bonobo_control_set_properties ( - priv->control, BONOBO_OBJREF (priv->prop_sack), NULL); - - priv->shell = panel_applet_shell_new (applet); - - bonobo_object_add_interface (BONOBO_OBJECT (priv->control), - BONOBO_OBJECT (priv->shell)); - - priv->item_handler = - bonobo_item_handler_new ( - NULL, panel_applet_item_handler_get_object, applet); - - bonobo_object_add_interface (BONOBO_OBJECT (priv->control), - BONOBO_OBJECT (priv->item_handler)); - - g_signal_connect (applet, "popup_menu", - G_CALLBACK (panel_applet_popup_menu), NULL); -} - GtkWidget * panel_applet_new (void) { @@ -1645,161 +1716,48 @@ applet = g_object_new (PANEL_TYPE_APPLET, NULL); - panel_applet_setup (applet); - return GTK_WIDGET (applet); } -typedef struct { - GType applet_type; - GClosure *closure; -} PanelAppletCallBackData; - -static PanelAppletCallBackData * -panel_applet_callback_data_new (GType applet_type, - GClosure *closure) -{ - PanelAppletCallBackData *retval; - - retval = g_new0 (PanelAppletCallBackData, 1); - - retval->applet_type = applet_type; - retval->closure = closure; - - return retval; -} - -static void -panel_applet_callback_data_free (PanelAppletCallBackData *data) -{ - g_closure_unref (data->closure); - g_free (data); -} - -static BonoboObject * -panel_applet_factory_callback (BonoboGenericFactory *factory, - const char *iid, - PanelAppletCallBackData *data) -{ - PanelApplet *applet; - - applet = g_object_new (data->applet_type, NULL); - - panel_applet_setup (applet); - - applet->priv->iid = g_strdup (iid); - applet->priv->closure = g_closure_ref (data->closure); - - bonobo_control_life_instrument (applet->priv->control); - - return BONOBO_OBJECT (applet->priv->control); -} - -static void -panel_applet_all_controls_dead (void) -{ - if (!bonobo_control_life_get_count()) - bonobo_main_quit (); -} - -int -panel_applet_factory_main_closure (const gchar *iid, - GType applet_type, - GClosure *closure) -{ - int retval; - char *display_iid; - PanelAppletCallBackData *data; - - g_return_val_if_fail (iid != NULL, 1); - g_return_val_if_fail (closure != NULL, 1); - - g_assert (g_type_is_a (applet_type, PANEL_TYPE_APPLET)); - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - - bonobo_control_life_set_callback (panel_applet_all_controls_dead); - - closure = bonobo_closure_store (closure, panel_applet_marshal_BOOLEAN__STRING); - - data = panel_applet_callback_data_new (applet_type, closure); - - display_iid = bonobo_activation_make_registration_id ( - iid, DisplayString (gdk_display)); - retval = bonobo_generic_factory_main ( - display_iid, - (BonoboFactoryCallback) panel_applet_factory_callback, - data); - g_free (display_iid); - - panel_applet_callback_data_free (data); - - return retval; -} - -int -panel_applet_factory_main (const gchar *iid, - GType applet_type, - PanelAppletFactoryCallback callback, - gpointer data) +static gboolean +panel_applet_get_xid (PanelApplet *applet, gint IN_screen, guint32 *OUT_xid, GError **error) { - GClosure *closure; + GdkScreen *screen; - g_return_val_if_fail (iid != NULL, 1); - g_return_val_if_fail (callback != NULL, 1); + if (IN_screen != -1) + screen = gdk_display_get_screen ( + gdk_display_get_default (), IN_screen); + else + screen = gdk_screen_get_default (); - closure = g_cclosure_new (G_CALLBACK (callback), data, NULL); + gtk_window_set_screen (GTK_WINDOW (applet->priv->plug), screen); + gtk_widget_show (applet->priv->plug); + + *OUT_xid = applet->priv->xid; - return panel_applet_factory_main_closure (iid, applet_type, closure); + return TRUE; } -Bonobo_Unknown -panel_applet_shlib_factory_closure (const char *iid, - GType applet_type, - PortableServer_POA poa, - gpointer impl_ptr, - GClosure *closure, - CORBA_Environment *ev) +static gboolean +panel_applet_popup_menu (PanelApplet *applet, guint IN_button, guint32 IN_time, GError **error) { - BonoboShlibFactory *factory; - - g_return_val_if_fail (iid != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (closure != NULL, CORBA_OBJECT_NIL); - - g_assert (g_type_is_a (applet_type, PANEL_TYPE_APPLET)); - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - - closure = bonobo_closure_store (closure, panel_applet_marshal_BOOLEAN__STRING); - - factory = bonobo_shlib_factory_new_closure ( - iid, poa, impl_ptr, - g_cclosure_new (G_CALLBACK (panel_applet_factory_callback), - panel_applet_callback_data_new (applet_type, closure), - (GClosureNotify) panel_applet_callback_data_free)); + panel_applet_popup_menu_full (applet, + (GtkMenuPositionFunc) panel_applet_position_menu, + applet, + IN_button, + IN_time); - return CORBA_Object_duplicate (BONOBO_OBJREF (factory), ev); + return TRUE; } -Bonobo_Unknown -panel_applet_shlib_factory (const char *iid, - GType applet_type, - PortableServer_POA poa, - gpointer impl_ptr, - PanelAppletFactoryCallback callback, - gpointer user_data, - CORBA_Environment *ev) +static gboolean +panel_applet_notify_add (PanelApplet *applet, const gchar *IN_property, GError **error) { - g_return_val_if_fail (iid != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (callback != NULL, CORBA_OBJECT_NIL); - - return panel_applet_shlib_factory_closure ( - iid, applet_type, poa, impl_ptr, - g_cclosure_new (G_CALLBACK (callback), - user_data, NULL), - ev); + g_hash_table_insert (applet->priv->notifies, + g_strdup (IN_property), + GINT_TO_POINTER (TRUE)); + + return TRUE; } void Index: libpanel-applet/panel-applet.h =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet.h,v retrieving revision 1.39 diff -u -u -r1.39 panel-applet.h --- libpanel-applet/panel-applet.h 28 Dec 2005 21:11:21 -0000 1.39 +++ libpanel-applet/panel-applet.h 30 Dec 2005 18:06:58 -0000 @@ -25,27 +25,18 @@ #ifndef __PANEL_APPLET_H__ #define __PANEL_APPLET_H__ +#include #include #include #include +#include #include #include -#include -#include -#include -#include +#include "panel-applet-menu.h" G_BEGIN_DECLS -typedef GNOME_Vertigo_PanelOrient PanelAppletOrient; - -#define PANEL_APPLET_ORIENT_UP GNOME_Vertigo_PANEL_ORIENT_UP -#define PANEL_APPLET_ORIENT_DOWN GNOME_Vertigo_PANEL_ORIENT_DOWN -#define PANEL_APPLET_ORIENT_LEFT GNOME_Vertigo_PANEL_ORIENT_LEFT -#define PANEL_APPLET_ORIENT_RIGHT GNOME_Vertigo_PANEL_ORIENT_RIGHT - - #define PANEL_TYPE_APPLET (panel_applet_get_type ()) #define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet)) #define PANEL_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET, PanelAppletClass)) @@ -54,6 +45,14 @@ #define PANEL_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET, PanelAppletClass)) typedef enum { + PANEL_APPLET_ORIENT_UP = 1 << 0, + PANEL_APPLET_ORIENT_RIGHT = 1 << 1, + PANEL_APPLET_ORIENT_DOWN = 1 << 2, + PANEL_APPLET_ORIENT_LEFT = 1 << 3 +} PanelAppletOrient; + + +typedef enum { PANEL_NO_BACKGROUND, PANEL_COLOR_BACKGROUND, PANEL_PIXMAP_BACKGROUND @@ -70,10 +69,6 @@ typedef struct _PanelAppletClass PanelAppletClass; typedef struct _PanelAppletPrivate PanelAppletPrivate; -typedef gboolean (*PanelAppletFactoryCallback) (PanelApplet *applet, - const gchar *iid, - gpointer user_data); - struct _PanelApplet { GtkEventBox event_box; @@ -97,82 +92,48 @@ GtkDirectionType direction); }; -GType panel_applet_get_type (void) G_GNUC_CONST; - -GtkWidget *panel_applet_new (void); +GType panel_applet_get_type (void) G_GNUC_CONST; -PanelAppletOrient panel_applet_get_orient (PanelApplet *applet); +GtkWidget *panel_applet_new (void); -guint panel_applet_get_size (PanelApplet *applet); +PanelAppletOrient panel_applet_get_orient (PanelApplet *applet); + +void panel_applet_set_size (PanelApplet *applet, + guint size); +guint panel_applet_get_size (PanelApplet *applet); PanelAppletBackgroundType - panel_applet_get_background (PanelApplet *applet, - /* return values */ - GdkColor *color, - GdkPixmap **pixmap); - -void panel_applet_set_background_widget (PanelApplet *applet, - GtkWidget *widget); - -gchar *panel_applet_get_preferences_key (PanelApplet *applet); - -void panel_applet_add_preferences (PanelApplet *applet, - const gchar *schema_dir, - GError **opt_error); - -PanelAppletFlags panel_applet_get_flags (PanelApplet *applet); -void panel_applet_set_flags (PanelApplet *applet, - PanelAppletFlags flags); - -void panel_applet_set_size_hints (PanelApplet *applet, - const int *size_hints, - int n_elements, - int base_size); - -gboolean panel_applet_get_locked_down (PanelApplet *applet); - -void panel_applet_request_focus (PanelApplet *applet, - guint32 timestamp); - -BonoboControl *panel_applet_get_control (PanelApplet *applet); -BonoboUIComponent *panel_applet_get_popup_component (PanelApplet *applet); - -void panel_applet_setup_menu (PanelApplet *applet, - const gchar *xml, - const BonoboUIVerb *verb_list, - gpointer user_data); - -void panel_applet_setup_menu_from_file (PanelApplet *applet, - const gchar *opt_datadir, - const gchar *file, - const gchar *opt_app_name, - const BonoboUIVerb *verb_list, - gpointer user_data); - - -int panel_applet_factory_main (const gchar *iid, - GType applet_type, - PanelAppletFactoryCallback callback, - gpointer data); - -int panel_applet_factory_main_closure (const gchar *iid, - GType applet_type, - GClosure *closure); - -Bonobo_Unknown panel_applet_shlib_factory (const char *iid, - GType applet_type, - PortableServer_POA poa, - gpointer impl_ptr, - PanelAppletFactoryCallback callback, - gpointer user_data, - CORBA_Environment *ev); - -Bonobo_Unknown panel_applet_shlib_factory_closure (const char *iid, - GType applet_type, - PortableServer_POA poa, - gpointer impl_ptr, - GClosure *closure, - CORBA_Environment *ev); + panel_applet_get_background (PanelApplet *applet, + /* return values */ + GdkColor *color, + GdkPixmap **pixmap); + +void panel_applet_set_background_widget (PanelApplet *applet, + GtkWidget *widget); + +gchar *panel_applet_get_preferences_key (PanelApplet *applet); + +void panel_applet_add_preferences (PanelApplet *applet, + const gchar *schema_dir, + GError **opt_error); + +PanelAppletFlags panel_applet_get_flags (PanelApplet *applet); +void panel_applet_set_flags (PanelApplet *applet, + PanelAppletFlags flags); + +void panel_applet_set_size_hints (PanelApplet *applet, + const int *size_hints, + int n_elements, + int base_size); + +gboolean panel_applet_get_locked_down (PanelApplet *applet); + +void panel_applet_request_focus (PanelApplet *applet, + guint32 timestamp); + +/* Menu */ +PanelAppletMenu *panel_applet_get_menu (PanelApplet *applet); + /* * These macros are getting a bit unwieldy. @@ -182,10 +143,10 @@ * GETTEXT_PACKAGE and GNOMELOCALEDIR * + optional : PREFIX, SYSCONFDIR, DATADIR and LIBDIR. */ - +#include "panel-applet-factory.h" #if !defined(ENABLE_NLS) #if defined(PREFIX) && defined(SYSCONFDIR) && defined(DATADIR) && defined(LIBDIR) -#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \ +#define PANEL_APPLET_FACTORY_MAIN(iid, type, name, version, callback, data) \ int main (int argc, char *argv []) \ { \ gnome_program_init (name, version, \ @@ -197,7 +158,7 @@ return panel_applet_factory_main (iid, type, callback, data); \ } #else /* !defined(PREFIX) ... */ -#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \ +#define PANEL_APPLET_FACTORY_MAIN(iid, type, name, version, callback, data) \ int main (int argc, char *argv []) \ { \ gnome_program_init (name, version, \ @@ -211,7 +172,7 @@ #else /* defined(ENABLE_NLS) */ #include #if defined(PREFIX) && defined(SYSCONFDIR) && defined(DATADIR) && defined(LIBDIR) -#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \ +#define PANEL_APPLET_FACTORY_MAIN(iid, type, name, version, callback, data) \ int main (int argc, char *argv []) \ { \ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); \ @@ -226,7 +187,7 @@ return panel_applet_factory_main (iid, type, callback, data); \ } #else /* !defined(PREFIX) ... */ -#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \ +#define PANEL_APPLET_FACTORY_MAIN(iid, type, name, version, callback, data) \ int main (int argc, char *argv []) \ { \ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); \ @@ -240,43 +201,6 @@ return panel_applet_factory_main (iid, type, callback, data); \ } #endif /* defined(PREFIX) ... */ -#endif /* !defined(ENABLE_NLS) */ - -#if !defined(ENABLE_NLS) -#define PANEL_APPLET_BONOBO_SHLIB_FACTORY(iid, type, descr, callback, data) \ -static Bonobo_Unknown \ -__panel_applet_shlib_factory (PortableServer_POA poa, \ - const char *oafiid, \ - gpointer impl_ptr, \ - CORBA_Environment *ev) \ -{ \ - return panel_applet_shlib_factory ((iid), (type), poa, impl_ptr, \ - (callback), (data), ev); \ -} \ -static BonoboActivationPluginObject plugin_list[] = { \ - { (iid), __panel_applet_shlib_factory }, \ - { NULL } \ -}; \ -const BonoboActivationPlugin Bonobo_Plugin_info = { plugin_list, (descr) }; -#else /* defined(ENABLE_NLS) */ -#include -#define PANEL_APPLET_BONOBO_SHLIB_FACTORY(iid, type, descr, callback, data) \ -static Bonobo_Unknown \ -__panel_applet_shlib_factory (PortableServer_POA poa, \ - const char *oafiid, \ - gpointer impl_ptr, \ - CORBA_Environment *ev) \ -{ \ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); \ - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \ - return panel_applet_shlib_factory ((iid), (type), poa, impl_ptr, \ - (callback), (data), ev); \ -} \ -static BonoboActivationPluginObject plugin_list[] = { \ - { (iid), __panel_applet_shlib_factory }, \ - { NULL } \ -}; \ -const BonoboActivationPlugin Bonobo_Plugin_info = { plugin_list, (descr) }; #endif /* !defined(ENABLE_NLS) */ G_END_DECLS Index: libpanel-applet/panel-applet.xml =================================================================== RCS file: libpanel-applet/panel-applet.xml diff -N libpanel-applet/panel-applet.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/panel-applet.xml 30 Dec 2005 18:06:58 -0000 @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: libpanel-applet/panel-test-applets.c =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-test-applets.c,v retrieving revision 1.7 diff -u -u -r1.7 panel-test-applets.c --- libpanel-applet/panel-test-applets.c 30 Dec 2005 10:36:45 -0000 1.7 +++ libpanel-applet/panel-test-applets.c 30 Dec 2005 18:06:58 -0000 @@ -3,316 +3,433 @@ * * Authors: * Mark McLoughlin + * Carlos Garcia Campos * * Copyright 2002 Sun Microsystems, Inc. */ #include +#include #include #include -#include -#include +#include +#include +#include #include -#include "panel-applet.h" +#include "panel-applet-manager.h" +#include "panel-applet-container.h" -void on_execute_button_clicked (GtkButton *button, gpointer dummy); -static GtkWidget *win = NULL; -static GtkWidget *applet_combo = NULL; +static void menu_remove_cb (GtkAction *action, gpointer gdata); + +static GtkWidget *applet_list = NULL; static GtkWidget *prefs_dir_entry = NULL; static GtkWidget *orient_combo = NULL; -static GtkWidget *size_combo = NULL; +static GtkWidget *size_spin = NULL; -static char *cli_iid = NULL; +static char *cli_id = NULL; static char *cli_prefs_dir = NULL; -static char *cli_size = NULL; +static guint cli_size = 24; static char *cli_orient = NULL; -static const struct poptOption options [] = { - { "iid", '\0', POPT_ARG_STRING, &cli_iid, 0, N_("Specify an applet IID to load"), NULL}, - { "prefs-dir", '\0', POPT_ARG_STRING, &cli_prefs_dir, 0, N_("Specify a gconf location in which the applet preferences should be stored"), NULL}, - { "size", '\0', POPT_ARG_STRING, &cli_size, 0, N_("Specify the initial size of the applet (xx-small, medium, large etc.)"), NULL}, - POPT_AUTOHELP - { "orient", '\0', POPT_ARG_STRING, &cli_orient, 0, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL}, - {NULL, '\0', 0, NULL, 0} +static const GOptionEntry options[] = +{ + { "id", 'i', 0, G_OPTION_ARG_STRING, &cli_id, N_("Specify an applet ID to load"), NULL }, + { "prefs-dir", 'p', 0, G_OPTION_ARG_STRING, &cli_prefs_dir, N_("Specify a gconf location in which the applet preferences should be stored"), NULL }, + { "size", 's', 0, G_OPTION_ARG_INT, &cli_size, N_("Specify the initial size in pixels of the applet"), NULL }, + { "orient", 'o', 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL }, + { NULL } }; enum { + COLUMN_ICON, COLUMN_TEXT, COLUMN_ITEM, NUMBER_COLUMNS }; -typedef struct { - const char *name; - const char *value; -} ComboItem; - -static ComboItem orient_items [] = { - { N_("Top"), "top" }, - { N_("Bottom"), "bottom" }, - { N_("Left"), "left" }, - { N_("Right"), "right" } +typedef enum { + ORIENTATION_TOP = 1 << 0, + ORIENTATION_RIGHT = 1 << 1, + ORIENTATION_BOTTOM = 1 << 2, + ORIENTATION_LEFT = 1 << 3 +} PanelOrientation; + +static const GtkActionEntry test_menu_actions[] = { + { "TestRemove", GTK_STOCK_REMOVE, N_("_Remove"), + NULL, NULL, + G_CALLBACK (menu_remove_cb) }, }; +static const gchar *test_menu_ui = +"\n" +" \n" +""; -static ComboItem size_items [] = { - { N_("XX Small"), "xx-small" }, - { N_("X Small"), "x-small" }, - { N_("Small"), "small" }, - { N_("Medium"), "medium" }, - { N_("Large"), "large" }, - { N_("X Large"), "x-large" }, - { N_("XX Large"), "xx-large" } -}; - -static char * -get_combo_value (GtkWidget *combo_box) +static void +menu_remove_cb (GtkAction *action, gpointer gdata) { - GtkTreeIter iter; - GtkTreeModel *model; - char *value; + GtkWidget *window = GTK_WIDGET (gdata); - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) - return NULL; + gtk_widget_destroy (window); +} - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); - gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1); +static PanelOrientation +get_orient_from_string (const gchar *str) +{ + if (g_ascii_strcasecmp (str, "Top") == 0) { + return ORIENTATION_TOP; + } else if (g_ascii_strcasecmp (str, "Bottom") == 0) { + return ORIENTATION_BOTTOM; + } else if (g_ascii_strcasecmp (str, "Left") == 0) { + return ORIENTATION_LEFT; + } else if (g_ascii_strcasecmp (str, "Right") == 0) { + return ORIENTATION_RIGHT; + } - return value; + return ORIENTATION_TOP; } -static char * -construct_moniker (void) +static PanelOrientation +get_orient_combo_value (void) { - const char *prefs_key; - char *iid; - char *size; - char *orient; - char *ret_value; + PanelOrientation orient; + gchar *item = NULL; + + item = gtk_combo_box_get_active_text (GTK_COMBO_BOX (orient_combo)); - iid = get_combo_value (applet_combo); - g_assert (iid != NULL); - size = get_combo_value (size_combo); - g_assert (size != NULL); - orient = get_combo_value (orient_combo); - g_assert (orient != NULL); + if (!item) + return ORIENTATION_TOP; - prefs_key = gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)); + orient = get_orient_from_string (item); + g_free (item); - ret_value= g_strdup_printf ("%s!prefs_key=%s;size=%s;orient=%s", - iid, prefs_key, size, orient); - g_free (iid); - g_free (size); - g_free (orient); - - return ret_value; + return orient; } -static void -load_applet_into_window (const char *moniker, - const char *title) +static gboolean +applet_activated (PanelAppletContainer *container, + GError *error, + gpointer user_data) { - GtkWidget *applet_window; - GtkWidget *applet; - - applet = bonobo_widget_new_control (moniker, NULL); - - if (!applet) { + GtkWidget *applet_window = GTK_WIDGET (user_data); + + if (error) { GtkWidget *dialog; - dialog = gtk_message_dialog_new (win ? GTK_WINDOW (win) : NULL, + dialog = gtk_message_dialog_new (applet_window ? GTK_WINDOW (applet_window) : NULL, GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Failed to load applet %s"), - title); + _("Failed to load applet\n%s"), + error->message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - return; + + g_clear_error (&error); + gtk_widget_destroy (applet_window); + + return FALSE; } - applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + panel_applet_container_menu_add_actions (PANEL_APPLET_CONTAINER (container), + test_menu_actions, + G_N_ELEMENTS (test_menu_actions), + user_data); + panel_applet_container_menu_add_ui_from_string (PANEL_APPLET_CONTAINER (container), + test_menu_ui); + + return TRUE; +} - gtk_widget_show (applet); +static void +destroy_window (GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + gtk_widget_destroy (widget); +} + +static void +load_applet_into_window (GtkWidget *applet_window, + const gchar *applet_id, + const gchar *prefs_key, + PanelOrientation orient, + guint size) +{ + GtkWidget *container; - gtk_container_add (GTK_CONTAINER (applet_window), applet); + container = panel_applet_container_new (); + gtk_container_add (GTK_CONTAINER (applet_window), container); + gtk_widget_show (container); + + panel_applet_container_add_with_properties (PANEL_APPLET_CONTAINER (container), + applet_id, + (PanelAppletActivateCb)applet_activated, + applet_window, + "orient", orient, + "prefs-key", prefs_key, + "size", size, NULL); //FIXME: we could set the window icon with the applet icon - gtk_window_set_title (GTK_WINDOW (applet_window), title); + gtk_window_set_title (GTK_WINDOW (applet_window), applet_id); gtk_widget_show (applet_window); } static void -load_applet_from_command_line (void) +load_applet_from_gui (void) { - GString *str; + PanelOrientation orient; + guint size; + const gchar *prefs_key; + GtkWidget *applet_window; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + gchar *applet_id = NULL; + + orient = get_orient_combo_value (); + size = gtk_spin_button_get_value_as_int ( + GTK_SPIN_BUTTON (size_spin)); + prefs_key = gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)); - g_assert (cli_iid != NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (applet_list)); + gtk_tree_selection_get_selected (selection, &model, &iter); - str = g_string_new (cli_iid); + gtk_tree_model_get (model, &iter, + COLUMN_ITEM, &applet_id, + -1); - if (cli_prefs_dir || cli_size || cli_orient) { - g_string_append_c (str, '!'); + applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (G_OBJECT (applet_window), "delete-event", + G_CALLBACK (destroy_window), NULL); + + load_applet_into_window (applet_window, applet_id, + prefs_key, orient, size); - if (cli_prefs_dir) - g_string_append_printf (str, "prefs_key=%s", cli_prefs_dir); + g_free (applet_id); +} - g_string_append_c (str, ';'); +static void +load_applet_from_command_line (void) +{ + PanelOrientation orient; + GtkWidget *applet_window; - if (cli_size) - g_string_append_printf (str, "size=%s", cli_size); + g_assert (cli_id != NULL); - g_string_append_c (str, ';'); + orient = (!cli_orient) ? ORIENTATION_TOP : get_orient_from_string (cli_orient); - if (cli_orient) - g_string_append_printf (str, "orient=%s", cli_orient); - } + applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (G_OBJECT (applet_window), "delete-event", + G_CALLBACK (gtk_main_quit), NULL); + g_signal_connect (G_OBJECT (applet_window), "destroy", + G_CALLBACK (gtk_main_quit), NULL); - g_print ("Loading %s\n", str->str); - - load_applet_into_window (str->str, cli_iid); - - g_string_free (str, TRUE); + load_applet_into_window (applet_window, cli_id, + cli_prefs_dir, + orient, cli_size); } -G_GNUC_UNUSED void -on_execute_button_clicked (GtkButton *button, - gpointer dummy) +static void +selection_changed (GtkTreeSelection *selection, + GtkWidget *button) { - char *moniker; - char *title; - - moniker = construct_moniker (); - title = get_combo_value (applet_combo); - load_applet_into_window (moniker, title); - g_free (moniker); - g_free (title); + gtk_widget_set_sensitive (button, + gtk_tree_selection_get_selected (selection, + NULL, NULL)); } -static void -setup_combo (GtkWidget *combo_box, - ComboItem *items, - int nb_items, - gboolean dynamic) -{ - GtkListStore *model; - GtkTreeIter iter; - GtkCellRenderer *renderer; - int i; - - model = gtk_list_store_new (NUMBER_COLUMNS, - G_TYPE_STRING, - G_TYPE_STRING); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), - GTK_TREE_MODEL (model)); - - - for (i = 0; i < nb_items; i++) { - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, - COLUMN_TEXT, dynamic ? g_strdup (items [i].name) : _(items [i].name), - COLUMN_ITEM, dynamic ? g_strdup (items [i].value) : items [i].value, +static GtkTreeModel * +create_model (void) +{ + GtkTreeModel *model; + PanelAppletManager *manager; + GList *applets = NULL, *l = NULL; + gint i; + + model = GTK_TREE_MODEL (gtk_list_store_new (NUMBER_COLUMNS, + GDK_TYPE_PIXBUF, + G_TYPE_STRING, + G_TYPE_STRING)); + + manager = panel_applet_manager_new (); + applets = panel_applet_manager_get_applets (manager); + + for (l = applets, i = 0; l; l = g_list_next (l), i++) { + PanelAppletInfo *info; + GtkTreeIter iter; + GdkPixbuf *pixbuf = NULL; + gchar *p, *icon_name = NULL; + gchar *text; + + info = (PanelAppletInfo *) l->data; + + if (info->icon) { + p = g_strrstr (info->icon, "."); + if (g_ascii_strcasecmp (p, ".png") == 0 || + g_ascii_strcasecmp (p, ".xpm") == 0 || + g_ascii_strcasecmp (p, ".svg") == 0) { + icon_name = g_strndup (info->icon, + strlen (info->icon) - strlen (p)); + } + + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + icon_name, 24, 0, NULL); + g_free (icon_name); + } + + text = g_markup_printf_escaped ("%s\n%s", + info->name, info->comment); + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COLUMN_ICON, pixbuf, + COLUMN_TEXT, text, + COLUMN_ITEM, info->id, -1); + + if (pixbuf) + g_object_unref (pixbuf); + g_free (text); + + panel_applet_info_free (info); } - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), - renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), - renderer, "text", COLUMN_TEXT, NULL); + g_list_free (applets); + g_object_unref (manager); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); + return model; } static void -setup_options (void) +setup_list (void) { - Bonobo_ServerInfoList *applets; - CORBA_Environment env; - int i; - char *prefs_dir; - char *unique_key; - ComboItem *applet_items; - int applet_nb; - - CORBA_exception_init (&env); - - applets = bonobo_activation_query ( - "has (repo_ids, 'IDL:GNOME/Vertigo/PanelAppletShell:1.0')", - NULL, &env); - - if (BONOBO_EX (&env)) - g_error (_("query returned exception %s\n"), BONOBO_EX_REPOID (&env)); - - CORBA_exception_free (&env); - - applet_nb = applets->_length; - applet_items = g_new0 (ComboItem, applet_nb); + GtkCellRenderer *renderer; + + gtk_tree_view_set_model (GTK_TREE_VIEW (applet_list), + create_model ()); - for (i = 0; i < applet_nb; i++) { - Bonobo_ServerInfo *info; + renderer = gtk_cell_renderer_pixbuf_new (); + g_object_set (G_OBJECT (renderer), + "xpad", 4, "ypad", 4, + NULL); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (applet_list), + -1, NULL, + renderer, + "pixbuf", COLUMN_ICON, + NULL); - info = &applets->_buffer [i]; + renderer = gtk_cell_renderer_text_new (); + g_object_set (G_OBJECT (renderer), + "ellipsize", PANGO_ELLIPSIZE_END, + NULL); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (applet_list), + -1, NULL, + renderer, + "markup", COLUMN_TEXT, + NULL); +} - applet_items[i].name = info->iid; - applet_items[i].value = info->iid; - } +static void +setup_options (void) +{ + char *prefs_dir; + char *unique_key; - setup_combo (applet_combo, applet_items, applet_nb, TRUE); - g_free (applet_items); - CORBA_free (applets); - - setup_combo (size_combo, size_items, G_N_ELEMENTS (size_items), FALSE); - setup_combo (orient_combo, orient_items, - G_N_ELEMENTS (orient_items), FALSE); + setup_list (); unique_key = gconf_unique_key (); prefs_dir = g_strdup_printf ("/tmp/%s", unique_key); g_free (unique_key); gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir); g_free (prefs_dir); + + gtk_combo_box_set_active (GTK_COMBO_BOX (orient_combo), 0); +} + +static void +quit (GtkWidget *w, GdkEvent *event, gpointer user_data) +{ + gtk_dialog_response (GTK_DIALOG (w), + GTK_RESPONSE_CLOSE); +} + +static void +dialog_response (GtkDialog *dialog, gint arg1, gpointer user_data) +{ + switch (arg1) { + case GTK_RESPONSE_OK: + load_applet_from_gui (); + break; + default: + gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_main_quit (); + } } int main (int argc, char **argv) { - GladeXML *gui; - char *gladefile; - - gnome_program_init (argv [0], "0.0.0.0", LIBGNOMEUI_MODULE, + GtkWidget *dialog; + GtkWidget *create_button; + GtkTreeSelection *selection; + GladeXML *gui; + char *gladefile; + GOptionContext *context; + + context = g_option_context_new ("Test Applets Utility"); + g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + + gnome_program_init (argv[0], "0.0.0.0", + LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_POPT_TABLE, options, + GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_NONE); - if (cli_iid) { + g_option_context_free (context); + + if (cli_id) { load_applet_from_command_line (); gtk_main (); + return 0; } - gladefile = PANEL_APPLET_GLADEDIR "/panel-test-applets.glade"; + gladefile = g_build_filename (PANEL_APPLET_GLADEDIR, "/panel-test-applets.glade", NULL); gui = glade_xml_new (gladefile, "toplevel", NULL); if (!gui) { g_warning ("Error loading `%s'", gladefile); + g_free (gladefile); + return 1; } + g_free (gladefile); - glade_xml_signal_autoconnect (gui); - - win = glade_xml_get_widget (gui, "toplevel"); - applet_combo = glade_xml_get_widget (gui, "applet-combo"); - prefs_dir_entry = glade_xml_get_widget (gui, "prefs-dir-entry"); - orient_combo = glade_xml_get_widget (gui, "orient-combo"); - size_combo = glade_xml_get_widget (gui, "size-combo"); + dialog = glade_xml_get_widget (gui, "toplevel"); + applet_list = glade_xml_get_widget (gui, "applet_list"); + prefs_dir_entry = glade_xml_get_widget (gui, "prefs_entry"); + orient_combo = glade_xml_get_widget (gui, "orient_combo"); + size_spin = glade_xml_get_widget (gui, "size_spin"); + + g_signal_connect (G_OBJECT (dialog), "delete-event", + G_CALLBACK (quit), NULL); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (dialog_response), NULL); setup_options (); - gtk_widget_show (win); + create_button = glade_xml_get_widget (gui, "create_button"); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (applet_list)); + g_signal_connect (G_OBJECT (selection), "changed", + G_CALLBACK (selection_changed), + (gpointer) create_button); + + gtk_widget_show (dialog); gtk_main (); + + g_object_unref (gui); return 0; } Index: libpanel-applet/panel-test-applets.glade =================================================================== RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-test-applets.glade,v retrieving revision 1.5 diff -u -u -r1.5 panel-test-applets.glade --- libpanel-applet/panel-test-applets.glade 30 Dec 2005 10:36:45 -0000 1.5 +++ libpanel-applet/panel-test-applets.glade 30 Dec 2005 18:06:58 -0000 @@ -4,10 +4,11 @@ + 6 True - Test applet utility + Test applets utility GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE + GTK_WIN_POS_CENTER False True False @@ -17,46 +18,104 @@ GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST True - False False - - + True False - 8 + 6 - + True GTK_BUTTONBOX_END - + True True True - gtk-execute + gtk-close True GTK_RELIEF_NORMAL True - 0 - + -7 - + True True True - gtk-close - True GTK_RELIEF_NORMAL True - -7 - + -5 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-new + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Create + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + @@ -69,210 +128,296 @@ - - 2 + True - 5 - 2 False - 4 - 4 - - - - True - _Size: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - size-combo - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 4 - 5 - - - - - - - - True - _Applet: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - applet-combo - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - - - - + 0 - + True - _Orientation: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - orient-combo - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 3 - 4 - - - - - - - - True - _Prefs Dir: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - prefs-dir-entry - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - - - - - - - True - False - True - - - 1 - 2 - 0 - 1 - fill - fill - - - - - - True - False - True - - - 1 - 2 - 3 - 4 - fill - fill - - - - - - True - False - True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + False + False + False + + + + + + + + + + True + <b>Applets</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + - 1 - 2 - 4 - 5 - fill - fill + 0 + True + True - + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + 3 + 2 + False + 6 + 6 + + + + True + _Preferences: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + prefs_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Orientation: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Size + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + size_spin + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + Top +Bottom +Left +Right + False + True + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 16 16 256 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + + + + + True + <b>Properties</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + - 0 - 2 - 1 - 2 - fill + 0 + False + True Index: libpanel-applet/test-applet.c =================================================================== RCS file: libpanel-applet/test-applet.c diff -N libpanel-applet/test-applet.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libpanel-applet/test-applet.c 30 Dec 2005 18:06:58 -0000 @@ -0,0 +1,186 @@ +/* + * test-applet.c: + * + * Authors: + * Carlos Garcia Campos + * + */ + +#include +#include +#include + +#include "panel-applet.h" + +typedef struct _TestApplet TestApplet; +typedef struct _TestAppletClass TestAppletClass; + +struct _TestApplet { + PanelApplet parent; + + GtkWidget *label; +}; + +struct _TestAppletClass { + PanelAppletClass parent_class; +}; + +static void test_applet_init (TestApplet *applet); +static void test_applet_class_init (TestAppletClass *klass); + +static void test_applet_preferences_cb (GtkAction *action, gpointer gdata); +static void test_applet_help_cb (GtkAction *action, gpointer gdata); +static void test_applet_about_cb (GtkAction *action, gpointer gdata); + +static void test_applet_change_background (PanelApplet *pa, PanelAppletBackgroundType type, + GdkColor *color, GdkPixmap *pixmap); + +static const GtkActionEntry test_applet_menu_actions[] = { + { "TestAppletPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), + NULL, NULL, + G_CALLBACK (test_applet_preferences_cb) }, + { "TestAppletHelp", GTK_STOCK_HELP, N_("_Help"), + NULL, NULL, + G_CALLBACK (test_applet_help_cb) }, + { "TestAppletAbout", GTK_STOCK_ABOUT, N_("_About"), + NULL, NULL, + G_CALLBACK (test_applet_about_cb) } +}; + +static const gchar *test_applet_menu_ui = +"\n" +" \n" +" \n" +" \n" +""; + +GType +test_applet_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (TestAppletClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) test_applet_class_init, + NULL, + NULL, + sizeof (TestApplet), + 0, + (GInstanceInitFunc) test_applet_init + }; + + type = g_type_register_static (PANEL_TYPE_APPLET, "TestApplet", + &info, 0); + } + + return type; +} + +static void +test_applet_init (TestApplet *applet) +{ + applet->label = gtk_label_new ("Hello World!"); + + gtk_container_set_border_width (GTK_CONTAINER (applet), 0); + + gtk_container_add (GTK_CONTAINER (applet), applet->label); + gtk_widget_show (applet->label); + + gtk_widget_show (GTK_WIDGET (applet)); +} + +static void +test_applet_class_init (TestAppletClass *klass) +{ + PanelAppletClass *applet_class = PANEL_APPLET_CLASS (klass); + + applet_class->change_background = test_applet_change_background; +} + +static void +test_applet_change_background (PanelApplet *pa, + PanelAppletBackgroundType type, + GdkColor *color, GdkPixmap *pixmap) +{ + TestApplet *applet; + /* Taken from TrashApplet */ + GtkRcStyle *rc_style; + GtkStyle *style; + + applet = (TestApplet *)pa; + + /* reset style */ + gtk_widget_set_style (GTK_WIDGET (applet), NULL); + rc_style = gtk_rc_style_new (); + gtk_widget_modify_style (GTK_WIDGET (applet), rc_style); + gtk_rc_style_unref (rc_style); + + switch (type) { + case PANEL_PIXMAP_BACKGROUND: + style = gtk_style_copy (GTK_WIDGET (applet)->style); + if (style->bg_pixmap[GTK_STATE_NORMAL]) + g_object_unref ( + style->bg_pixmap[GTK_STATE_NORMAL]); + style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref ( + pixmap); + gtk_widget_set_style (GTK_WIDGET (applet), style); + g_object_unref (style); + break; + case PANEL_COLOR_BACKGROUND: + gtk_widget_modify_bg (GTK_WIDGET (applet), + GTK_STATE_NORMAL, color); + break; + case PANEL_NO_BACKGROUND: + default: + break; + } +} + +static void +test_applet_preferences_cb (GtkAction *action, gpointer gdata) +{ + g_print ("preferences\n"); +} + +static void +test_applet_help_cb (GtkAction *action, gpointer gdata) +{ + g_print ("help\n"); +} + +static void +test_applet_about_cb (GtkAction *action, gpointer gdata) +{ + g_print ("about\n"); +} + +static gboolean +test_applet_setup (TestApplet *applet, const gchar *id, gpointer gdata) +{ + PanelAppletMenu *menu; + + if (g_ascii_strcasecmp (id, "Test Applet") != 0) + return FALSE; + + menu = panel_applet_get_menu (PANEL_APPLET (applet)); + panel_applet_menu_add_actions (menu, + test_applet_menu_actions, + G_N_ELEMENTS (test_applet_menu_actions), + applet); + panel_applet_menu_add_ui_from_string (menu, + test_applet_menu_ui); + + return TRUE; +} + + +PANEL_APPLET_FACTORY_MAIN ("TestApplet", + test_applet_get_type (), + "Test Applet", + "0.1", + (PanelAppletFactoryCallback) test_applet_setup, + NULL) + Index: po/POTFILES.in =================================================================== RCS file: /cvs/gnome/gnome-panel/po/POTFILES.in,v retrieving revision 1.163 diff -u -u -r1.163 POTFILES.in --- po/POTFILES.in 3 Dec 2005 20:45:56 -0000 1.163 +++ po/POTFILES.in 30 Dec 2005 18:06:58 -0000 @@ -2,24 +2,24 @@ # Please keep this file sorted alphabetically. [encoding: UTF-8] applets/clock/GNOME_ClockApplet.xml -applets/clock/GNOME_ClockApplet_Factory.server.in.in applets/clock/calendar-client.c applets/clock/clock.c applets/clock/clock.schemas.in +applets/clock/org.gnome.panel.applet.Clock.service.in.in applets/fish/GNOME_FishApplet.xml -applets/fish/GNOME_FishApplet_Factory.server.in.in applets/fish/fish.c applets/fish/fish.glade applets/fish/fish.schemas.in -applets/notification_area/GNOME_NotificationAreaApplet.server.in.in +applets/fish/org.gnome.panel.applet.Fish.service.in.in applets/notification_area/GNOME_NotificationAreaApplet.xml applets/notification_area/eggtraymanager.c applets/notification_area/main.c +applets/notification_area/org.gnome.panel.applet.NotificationArea.service.in.in applets/wncklet/GNOME_ShowDesktopApplet.xml applets/wncklet/GNOME_WindowListApplet.xml applets/wncklet/GNOME_WindowMenuApplet.xml -applets/wncklet/GNOME_Wncklet_Factory.server.in.in applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml +applets/wncklet/org.gnome.panel.applet.Wncklet.service.in.in applets/wncklet/showdesktop.c applets/wncklet/window-list.c applets/wncklet/window-list.glade @@ -29,7 +29,7 @@ applets/wncklet/workspace-switcher.c applets/wncklet/workspace-switcher.glade applets/wncklet/workspace-switcher.schemas.in -gnome-panel/GNOME_Panel.server.in +gnome-applets-manager/applets-manager.c gnome-panel/GNOME_Panel_Popup.xml gnome-panel/applet.c gnome-panel/button-widget.c @@ -66,7 +66,7 @@ gnome-panel/panel-toplevel.schemas.in gnome-panel/panel-util.c gnome-panel/panel.c -libpanel-applet/GNOME_Panel_TestApplet.server.in libpanel-applet/panel-applet.c libpanel-applet/panel-test-applets.c libpanel-applet/panel-test-applets.glade +libpanel-applet/test-applet.c