[gnome-main-menu] Port the application browser to libunique
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-main-menu] Port the application browser to libunique
- Date: Thu, 23 Jul 2009 23:01:00 +0000 (UTC)
commit 790a6389dcdfed041ba7d4d359bc50efd454cd51
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Jul 1 12:19:05 2009 +0200
Port the application browser to libunique
application-browser/src/application-browser.c | 51 ++++++++++++++++++-------
configure.in | 17 +--------
2 files changed, 38 insertions(+), 30 deletions(-)
---
diff --git a/application-browser/src/application-browser.c b/application-browser/src/application-browser.c
index afb012d..1a13621 100644
--- a/application-browser/src/application-browser.c
+++ b/application-browser/src/application-browser.c
@@ -27,21 +27,43 @@
#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/libgnomeui.h>
#include <dirent.h>
+#include <unique/unique.h>
#include <stdlib.h>
#include "app-shell.h"
-#include "app-shell-startup.h"
#include "slab-gnome-util.h"
#define APPLICATION_BROWSER_PREFIX "/desktop/gnome/applications/main-menu/ab_"
#define NEW_APPS_MAX_ITEMS (APPLICATION_BROWSER_PREFIX "new_apps_max_items")
+#define COMMAND_NEW_INSTANCE 1
+
+static UniqueResponse
+unique_app_message_cb (UniqueApp *app, gint command, UniqueMessageData *data,
+ guint time, gpointer user_data)
+{
+ AppShellData *app_data = user_data;
+ gboolean visible;
+
+ if (command != COMMAND_NEW_INSTANCE)
+ return UNIQUE_RESPONSE_PASSTHROUGH;
+
+ g_object_get (app_data->main_app, "visible", &visible, NULL);
+
+ if (!visible)
+ show_shell (app_data);
+
+
+ gtk_window_present (GTK_WINDOW (app_data->main_app));
+ gtk_widget_grab_focus (SLAB_SECTION (app_data->filter_section)->contents);
+
+ return UNIQUE_RESPONSE_OK;
+}
int
main (int argc, char *argv[])
{
- BonoboApplication *bonobo_app = NULL;
+ UniqueApp *unique_app = NULL;
gboolean hidden = FALSE;
- gchar * startup_id;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -61,16 +83,18 @@ main (int argc, char *argv[])
hidden = TRUE;
}
- startup_id = g_strdup (g_getenv (DESKTOP_STARTUP_ID));
gnome_program_init ("Gnome Application Browser", "0.1", LIBGNOMEUI_MODULE,
argc, argv, NULL, NULL);
- if (apss_already_running (argc, argv, &bonobo_app, "GNOME-NLD-AppBrowser", startup_id))
+ unique_app = unique_app_new_with_commands ("org.gnome.MainMenu", NULL,
+ "new_instance", COMMAND_NEW_INSTANCE, NULL);
+
+ if (unique_app_is_running (unique_app))
{
- gdk_notify_startup_complete ();
- bonobo_debug_shutdown ();
- g_free (startup_id);
- exit (1);
+ unique_app_send_message (unique_app, COMMAND_NEW_INSTANCE, NULL);
+ g_object_unref (unique_app);
+
+ return 0;
}
NewAppConfig *config = g_new0 (NewAppConfig, 1);
@@ -82,13 +106,12 @@ main (int argc, char *argv[])
layout_shell (app_data, _("Filter"), _("Groups"), _("Application Actions"), NULL, NULL);
- g_signal_connect (bonobo_app, "new-instance", G_CALLBACK (apss_new_instance_cb), app_data);
+ g_signal_connect (unique_app, "message-received", G_CALLBACK (unique_app_message_cb), app_data);
+
create_main_window (app_data, "MyApplicationBrowser", _("Application Browser"),
"gnome-fs-client", 940, 600, hidden);
- if (bonobo_app)
- bonobo_object_unref (bonobo_app);
- bonobo_debug_shutdown ();
- g_free (startup_id);
+ g_object_unref (unique_app);
+
return 0;
};
diff --git a/configure.in b/configure.in
index 38ad90b..44a7a29 100644
--- a/configure.in
+++ b/configure.in
@@ -71,27 +71,12 @@ fi
AC_SUBST(MAIN_MENU_CFLAGS)
AC_SUBST(MAIN_MENU_LIBS)
-PKG_CHECK_MODULES(APPLICATION_BROWSER, [ $COMMON_MODULES libpanelapplet-2.0 gnome-desktop-2.0 libgnomeui-2.0 libgnome-menu ])
+PKG_CHECK_MODULES(APPLICATION_BROWSER, [ $COMMON_MODULES libpanelapplet-2.0 gnome-desktop-2.0 libgnomeui-2.0 libgnome-menu unique-1.0 ])
AC_SUBST(APPLICATION_BROWSER_CFLAGS)
AC_SUBST(APPLICATION_BROWSER_LIBS)
dnl ==============================================
-dnl How to build libslab?
-dnl ==============================================
-
-ENABLE_DYNAMIC_LIBSLAB=1
-AC_ARG_ENABLE(dynamic-libslab,
- AC_HELP_STRING([--enable-dynamic-libslab], [Enable dynamic libslab]),
- [ENABLE_DYNAMIC_LIBSLAB=1])
-
-AM_CONDITIONAL(ENABLE_DYNAMIC_LIBSLAB, test "x$ENABLE_DYNAMIC_LIBSLAB" = "x1")
-
-dnl ==============================================
-dnl End: How to build libslab?
-dnl ==============================================
-
-dnl ==============================================
dnl Gconf
dnl ==============================================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]