~ubuntu-branches/debian/sid/gnome-main-menu/sid

« back to all changes in this revision

Viewing changes to application-browser/src/application-browser.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2009-11-08 21:22:49 UTC
  • mto: (5.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20091108212249-9cql8cptajeua2eh
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <string.h>
24
24
 
25
25
#include <gtk/gtk.h>
26
 
#include <gtk/gtkhbox.h>
27
 
#include <gtk/gtklabel.h>
28
 
#include <gtk/gtkimage.h>
29
 
#include <gtk/gtkvbox.h>
30
 
#include <gtk/gtktable.h>
31
 
#include <gtk/gtkbutton.h>
32
 
#include <gtk/gtktogglebutton.h>
33
 
#include <gtk/gtkentry.h>
34
 
#include <panel-applet.h>
35
26
#include <libgnome/gnome-desktop-item.h>
36
 
#include <libgnomeui/libgnomeui.h>
37
 
#include <dirent.h>
38
 
 
39
 
#include "app-shell.h"
40
 
#include "app-shell-startup.h"
41
 
#include "slab-gnome-util.h"
 
27
#include <unique/unique.h>
 
28
#include <stdlib.h>
 
29
#include <glib/gi18n.h>
 
30
#include <libslab/slab.h>
42
31
 
43
32
#define APPLICATION_BROWSER_PREFIX  "/desktop/gnome/applications/main-menu/ab_"
44
33
#define NEW_APPS_MAX_ITEMS  (APPLICATION_BROWSER_PREFIX "new_apps_max_items")
45
34
 
 
35
static UniqueResponse
 
36
unique_app_message_cb (UniqueApp *app, gint command, UniqueMessageData *data,
 
37
                       guint time, gpointer user_data)
 
38
{
 
39
        AppShellData *app_data = user_data;
 
40
 
 
41
        if (command != UNIQUE_ACTIVATE)
 
42
                return UNIQUE_RESPONSE_PASSTHROUGH;
 
43
 
 
44
        /* move the main window to the screen that sent us the command */
 
45
        gtk_window_set_screen (GTK_WINDOW (app_data->main_app),
 
46
                               unique_message_data_get_screen (data));
 
47
        if (!app_data->main_app_window_shown_once)
 
48
                show_shell (app_data);
 
49
 
 
50
        gtk_window_present_with_time (GTK_WINDOW (app_data->main_app), time);
 
51
        gtk_widget_grab_focus (SLAB_SECTION (app_data->filter_section)->contents);
 
52
 
 
53
        return UNIQUE_RESPONSE_OK;
 
54
}
 
55
 
46
56
int
47
57
main (int argc, char *argv[])
48
58
{
49
 
        BonoboApplication *bonobo_app = NULL;
 
59
        UniqueApp *unique_app = NULL;
50
60
        gboolean hidden = FALSE;
51
 
        gchar * startup_id;
 
61
        GError *error;
 
62
        GOptionEntry options[] = {
 
63
          { "hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL },
 
64
          { NULL }
 
65
        };
52
66
 
53
67
#ifdef ENABLE_NLS
54
68
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
56
70
        textdomain (GETTEXT_PACKAGE);
57
71
#endif
58
72
 
59
 
        if (argc > 1)
60
 
        {
61
 
                if (argc != 2 || strcmp ("-h", argv[1]))
62
 
                {
63
 
                        printf ("Usage - application-browser [-h]\n");
64
 
                        printf ("Options: -h : hide on start\n");
65
 
                        printf ("\tUseful if you want to autostart the application-browser singleton so it can get all it's slow loading done\n");
66
 
                        exit (1);
67
 
                }
68
 
                hidden = TRUE;
 
73
        error = NULL;
 
74
        if (!gtk_init_with_args (&argc, &argv,
 
75
                                 NULL, options, GETTEXT_PACKAGE, &error)) {
 
76
                g_printerr ("%s\n", error->message);
 
77
                g_error_free (error);
 
78
                return 1;
69
79
        }
70
80
 
71
 
        startup_id = g_strdup (g_getenv (DESKTOP_STARTUP_ID));
72
 
        gnome_program_init ("Gnome Application Browser", "0.1", LIBGNOMEUI_MODULE,
73
 
                argc, argv, NULL, NULL);
 
81
        unique_app = unique_app_new ("org.gnome.MainMenu", NULL);
74
82
 
75
 
        if (apss_already_running (argc, argv, &bonobo_app, "GNOME-NLD-AppBrowser", startup_id))
 
83
        if (unique_app_is_running (unique_app))
76
84
        {
77
 
                gdk_notify_startup_complete ();
78
 
                bonobo_debug_shutdown ();
79
 
                g_free (startup_id);
80
 
                exit (1);
 
85
                unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
 
86
                g_object_unref (unique_app);
 
87
 
 
88
                return 0;
81
89
        }
82
90
 
83
91
        NewAppConfig *config = g_new0 (NewAppConfig, 1);
89
97
 
90
98
        layout_shell (app_data, _("Filter"), _("Groups"), _("Application Actions"), NULL, NULL);
91
99
 
92
 
        g_signal_connect (bonobo_app, "new-instance", G_CALLBACK (apss_new_instance_cb), app_data);
93
100
        create_main_window (app_data, "MyApplicationBrowser", _("Application Browser"),
94
101
                "gnome-fs-client", 940, 600, hidden);
95
102
 
96
 
        if (bonobo_app)
97
 
                bonobo_object_unref (bonobo_app);
98
 
        bonobo_debug_shutdown ();
99
 
        g_free (startup_id);
 
103
        unique_app_watch_window (unique_app, GTK_WINDOW (app_data->main_app));
 
104
        g_signal_connect (unique_app, "message-received", G_CALLBACK (unique_app_message_cb), app_data);
 
105
 
 
106
        gtk_main ();
 
107
 
 
108
        g_object_unref (unique_app);
 
109
 
100
110
        return 0;
101
111
};