[gnome-packagekit] Port to GApplication
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Port to GApplication
- Date: Tue, 8 Jun 2010 17:51:30 +0000 (UTC)
commit dd604700eadc27dcfc8d0db8891c81118358eef1
Author: Richard Hughes <richard hughsie com>
Date: Tue Jun 8 18:20:02 2010 +0100
Port to GApplication
configure.ac | 5 +--
contrib/gnome-packagekit.spec.in | 22 +++++---------
src/Makefile.am | 2 -
src/gpk-application-main.c | 47 ++++++++++++-----------------
src/gpk-log.c | 60 +++++++++++++++++++++++--------------
src/gpk-prefs.c | 28 ++++++-----------
src/gpk-repo.c | 28 ++++++-----------
src/gpk-service-pack.c | 56 +++++++++++++++++++++--------------
src/gpk-update-icon.c | 29 ++++++++++--------
src/gpk-update-viewer-main.c | 41 +++++++++++--------------
src/gpk-update-viewer.c | 1 -
11 files changed, 153 insertions(+), 166 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1e62ab2..9699e7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,9 +110,8 @@ DBUS_REQUIRED=1.1.2
GCONF_REQUIRED=2.31.1
DBUS_GLIB_REQUIRED=0.73
LIBNOTIFY_REQUIRED=0.4.3
-UNIQUE_REQUIRED=1.0.0
GNOME_MENUS_REQUIRED=2.24.1
-GIO_REQUIRED=2.25.1
+GIO_REQUIRED=2.25.8
UPOWER_REQUIRED=0.9.0
CANBERRA_REQUIRED=0.10
@@ -135,8 +134,6 @@ PKG_CHECK_MODULES(LIBNOTIFY, \
libnotify >= $LIBNOTIFY_REQUIRED)
PKG_CHECK_MODULES(GNOME_MENUS, \
libgnome-menu >= $GNOME_MENUS_REQUIRED)
-PKG_CHECK_MODULES(UNIQUE, \
- unique-1.0 >= $UNIQUE_REQUIRED)
PKG_CHECK_MODULES(UPOWER, [
upower-glib >= $UPOWER_REQUIRED])
PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk >= $CANBERRA_REQUIRED)
diff --git a/contrib/gnome-packagekit.spec.in b/contrib/gnome-packagekit.spec.in
index 9ca5af7..cf80465 100644
--- a/contrib/gnome-packagekit.spec.in
+++ b/contrib/gnome-packagekit.spec.in
@@ -11,12 +11,7 @@ Group: Applications/System
URL: http://www.packagekit.org
Source0: http://download.gnome.org/sources/gnome-packagekit/2.30/%{name}-%{version}.tar.gz
-Requires: glib2 >= 2.18.0
-Requires: gtk2 >= 2.16.0
Requires: gnome-icon-theme
-Requires: libnotify >= 0.4.3
-Requires: unique >= 1.0.0
-Requires: dbus-glib >= 0.73
Requires: dbus-x11 >= 1.1.2
Requires: PackageKit >= 0.5.0
Requires: PackageKit-libs >= 0.5.0
@@ -34,12 +29,12 @@ Provides: pirut = 1.3.31-2
# required because KPackageKit provides exactly the same interface
Provides: PackageKit-session-service
-BuildRequires: glib2-devel >= %{glib2_version}
-BuildRequires: gtk2-devel >= %{gtk2_version}
+BuildRequires: glib2-devel >= 2.25.8
+BuildRequires: gtk2-devel >= 2.18.1
BuildRequires: libwnck-devel
-BuildRequires: dbus-devel >= %{dbus_version}
-BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
-BuildRequires: libnotify-devel >= %{libnotify_version}
+BuildRequires: dbus-devel
+BuildRequires: dbus-glib-devel
+BuildRequires: libnotify-devel
BuildRequires: gnome-panel-devel
BuildRequires: scrollkeeper
BuildRequires: gnome-doc-utils >= 0.3.2
@@ -51,14 +46,13 @@ BuildRequires: startup-notification-devel
BuildRequires: perl(XML::Parser)
BuildRequires: gnome-doc-utils
BuildRequires: gnome-menus-devel >= 2.24.1
-BuildRequires: PackageKit-devel >= %{packagekit_version}
-BuildRequires: unique-devel >= %{unique_version}
+BuildRequires: PackageKit-devel >= 0.5.0
BuildRequires: intltool
BuildRequires: xorg-x11-proto-devel
BuildRequires: fontconfig-devel
-BuildRequires: libcanberra-devel >= %{libcanberra_version}
+BuildRequires: libcanberra-devel
BuildRequires: libgudev1-devel
-BuildRequires: upower-devel >= %{upower_version}
+BuildRequires: upower-devel >= 0.9.0
%description
gnome-packagekit provides session applications for the PackageKit API.
diff --git a/src/Makefile.am b/src/Makefile.am
index acb2b3e..4c401fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,6 @@ INCLUDES = \
$(DBUS_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(PACKAGEKIT_CFLAGS) \
- $(UNIQUE_CFLAGS) \
$(GTK_CFLAGS) \
$(GUDEV_CFLAGS) \
$(GNOME_MENUS_CFLAGS) \
@@ -99,7 +98,6 @@ shared_LIBS = \
$(GUDEV_LIBS) \
$(LIBNOTIFY_LIBS) \
$(PACKAGEKIT_LIBS) \
- $(UNIQUE_LIBS) \
$(GNOME_MENUS_LIBS) \
$(UPOWER_LIBS) \
$(CANBERRA_LIBS) \
diff --git a/src/gpk-application-main.c b/src/gpk-application-main.c
index 1910957..623717f 100644
--- a/src/gpk-application-main.c
+++ b/src/gpk-application-main.c
@@ -30,7 +30,6 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include <locale.h>
-#include <unique/unique.h>
#include "egg-debug.h"
@@ -39,24 +38,21 @@
/**
* gpk_application_close_cb
- * @application: This application class instance
- *
- * What to do when we are asked to close for whatever reason
**/
static void
-gpk_application_close_cb (GpkApplication *application)
+gpk_application_close_cb (GpkApplication *app, GApplication *application)
{
- gtk_main_quit ();
+ g_application_quit (application, 0);
}
/**
- * gpk_application_message_received_cb
+ * gpk_application_prepare_action_cb:
**/
static void
-gpk_application_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, GpkApplication *application)
+gpk_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, GpkApplication *app)
{
- if (command == UNIQUE_ACTIVATE)
- gpk_application_show (application);
+ gpk_application_show (app);
}
/**
@@ -66,9 +62,9 @@ int
main (int argc, char *argv[])
{
gboolean program_version = FALSE;
- GpkApplication *application = NULL;
+ GpkApplication *app = NULL;
GOptionContext *context;
- UniqueApp *unique_app;
+ GApplication *application;
gboolean ret;
const GOptionEntry options[] = {
@@ -108,27 +104,22 @@ main (int argc, char *argv[])
if (!ret)
return 1;
+ /* create a new application object */
+ app = gpk_application_new ();
+
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.Application", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.Application", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_application_prepare_action_cb), app);
- /* create a new application object */
- application = gpk_application_new ();
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_application_message_received_cb), application);
- g_signal_connect (application, "action-close",
- G_CALLBACK (gpk_application_close_cb), NULL);
+ g_signal_connect (app, "action-close",
+ G_CALLBACK (gpk_application_close_cb), application);
- /* wait */
- gtk_main ();
+ /* run */
+ g_application_run (application);
+ g_object_unref (app);
g_object_unref (application);
-unique_out:
- g_object_unref (unique_app);
return 0;
}
diff --git a/src/gpk-log.c b/src/gpk-log.c
index 3fe9162..20ae507 100644
--- a/src/gpk-log.c
+++ b/src/gpk-log.c
@@ -30,7 +30,6 @@
#include <pwd.h>
#include <packagekit-glib2/packagekit.h>
-#include <unique/unique.h>
#include "egg-debug.h"
@@ -363,16 +362,15 @@ gpk_log_treeview_clicked_cb (GtkTreeSelection *selection, gpointer data)
}
/**
- * gpk_log_message_received_cb
+ * gpk_log_application_prepare_action_cb:
**/
static void
-gpk_log_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
+gpk_log_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
{
GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_simple"));
- gtk_window_present (window);
- }
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_simple"));
+ gtk_window_present (window);
}
/**
@@ -668,6 +666,25 @@ gpk_log_entry_filter_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_da
}
/**
+ * gpk_log_delete_event_cb:
+ **/
+static gboolean
+gpk_log_delete_event_cb (GtkWidget *widget, GdkEvent *event, GApplication *application)
+{
+ g_application_quit (application, 0);
+ return FALSE;
+}
+
+/**
+ * gpk_log_button_close_cb:
+ **/
+static void
+gpk_log_button_close_cb (GtkWidget *widget, GApplication *application)
+{
+ g_application_quit (application, 0);
+}
+
+/**
* main:
**/
int
@@ -678,7 +695,7 @@ main (int argc, char *argv[])
GtkWidget *widget;
GtkTreeSelection *selection;
GtkEntryCompletion *completion;
- UniqueApp *unique_app;
+ GApplication *application;
gboolean ret;
guint retval;
guint xid = 0;
@@ -719,14 +736,9 @@ main (int argc, char *argv[])
return 1;
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.LogViewer", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_log_message_received_cb), NULL);
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.LogViewer", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_log_application_prepare_action_cb), NULL);
/* add application specific icons to search path */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -752,17 +764,19 @@ main (int argc, char *argv[])
/* set a size, if the screen allows */
gpk_window_set_size_request (GTK_WINDOW (widget), 900, 300);
+ /* Get the main window quit */
+ g_signal_connect (widget, "delete-event",
+ G_CALLBACK (gpk_log_delete_event_cb), application);
+
/* if command line arguments are set, then setup UI */
if (filter != NULL) {
widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package"));
gtk_entry_set_text (GTK_ENTRY(widget), filter);
}
- /* Get the main window quit */
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_log_button_close_cb), application);
gtk_widget_grab_default (widget);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
@@ -826,7 +840,8 @@ main (int argc, char *argv[])
/* get the update list */
gpk_log_refresh ();
- gtk_main ();
+ /* run */
+ g_application_run (application);
out_build:
g_object_unref (builder);
@@ -836,7 +851,6 @@ out_build:
g_free (filter);
if (transactions != NULL)
g_ptr_array_unref (transactions);
-unique_out:
- g_object_unref (unique_app);
+ g_object_unref (application);
return 0;
}
diff --git a/src/gpk-prefs.c b/src/gpk-prefs.c
index ca7e2bb..dc65c49 100644
--- a/src/gpk-prefs.c
+++ b/src/gpk-prefs.c
@@ -31,7 +31,6 @@
#include <string.h>
#include <dbus/dbus-glib.h>
#include <packagekit-glib2/packagekit.h>
-#include <unique/unique.h>
#include <gpk-common.h>
#include <gpk-gnome.h>
@@ -289,16 +288,15 @@ gpk_prefs_auto_update_combo_setup (void)
}
/**
- * gpk_prefs_message_received_cb
+ * gpk_prefs_application_prepare_action_cb:
**/
static void
-gpk_prefs_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
+gpk_prefs_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
{
GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_prefs"));
- gtk_window_present (window);
- }
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_prefs"));
+ gtk_window_present (window);
}
/**
@@ -396,7 +394,7 @@ main (int argc, char *argv[])
GtkWidget *main_window;
GtkWidget *widget;
PkControl *control;
- UniqueApp *unique_app;
+ GApplication *application;
guint retval;
guint xid = 0;
GError *error = NULL;
@@ -438,14 +436,9 @@ main (int argc, char *argv[])
}
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.Prefs", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_prefs_message_received_cb), NULL);
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.Prefs", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_prefs_application_prepare_action_cb), NULL);
/* load settings */
settings = g_settings_new (GPK_SETTINGS_SCHEMA);
@@ -510,8 +503,7 @@ out_build:
g_object_unref (control);
g_object_unref (builder);
g_object_unref (settings);
-unique_out:
- g_object_unref (unique_app);
+ g_object_unref (application);
return 0;
}
diff --git a/src/gpk-repo.c b/src/gpk-repo.c
index e594de3..41e9f23 100644
--- a/src/gpk-repo.c
+++ b/src/gpk-repo.c
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <packagekit-glib2/packagekit.h>
-#include <unique/unique.h>
#include "egg-debug.h"
@@ -504,16 +503,15 @@ gpk_repo_checkbutton_detail_cb (GtkWidget *widget, gpointer data)
}
/**
- * gpk_repo_message_received_cb
+ * gpk_repo_application_prepare_action_cb:
**/
static void
-gpk_repo_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
+gpk_repo_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
{
GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_repo"));
- gtk_window_present (window);
- }
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_repo"));
+ gtk_window_present (window);
}
@@ -602,7 +600,7 @@ main (int argc, char *argv[])
GtkWidget *widget;
GtkTreeSelection *selection;
PkControl *control;
- UniqueApp *unique_app;
+ GApplication *application;
GError *error = NULL;
guint retval;
guint xid = 0;
@@ -646,14 +644,9 @@ main (int argc, char *argv[])
GPK_DATA G_DIR_SEPARATOR_S "icons");
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.Repo", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_repo_message_received_cb), NULL);
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.Repo", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_repo_application_prepare_action_cb), NULL);
settings = g_settings_new (GPK_SETTINGS_SCHEMA);
@@ -749,8 +742,7 @@ out_build:
g_object_unref (control);
g_object_unref (client);
g_main_loop_unref (loop);
-unique_out:
- g_object_unref (unique_app);
+ g_object_unref (application);
return 0;
}
diff --git a/src/gpk-service-pack.c b/src/gpk-service-pack.c
index eef7b43..9d2c6f5 100644
--- a/src/gpk-service-pack.c
+++ b/src/gpk-service-pack.c
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#include <sys/utsname.h>
#include <packagekit-glib2/packagekit.h>
-#include <unique/unique.h>
#include "egg-debug.h"
#include "egg-string.h"
@@ -616,16 +615,15 @@ out:
}
/**
- * gpk_pack_message_received_cb
+ * gpk_pack_application_prepare_action_cb:
**/
static void
-gpk_pack_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
+gpk_pack_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
{
GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "window_prefs"));
- gtk_window_present (window);
- }
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "window_prefs"));
+ gtk_window_present (window);
}
/**
@@ -674,6 +672,25 @@ gpk_pack_radio_copy_cb (GtkWidget *widget2, gpointer data)
}
/**
+ * gpk_pack_delete_event_cb:
+ **/
+static gboolean
+gpk_pack_delete_event_cb (GtkWidget *widget, GdkEvent *event, GApplication *application)
+{
+ g_application_quit (application, 0);
+ return FALSE;
+}
+
+/**
+ * gpk_pack_button_close_cb:
+ **/
+static void
+gpk_pack_button_close_cb (GtkWidget *widget, GApplication *application)
+{
+ g_application_quit (application, 0);
+}
+
+/**
* main:
**/
int
@@ -684,7 +701,7 @@ main (int argc, char *argv[])
GtkWidget *widget;
GtkFileFilter *filter;
GtkEntryCompletion *completion;
- UniqueApp *unique_app;
+ GApplication *application;
gboolean ret;
GSettings *settings = NULL;
gchar *option = NULL;
@@ -736,14 +753,9 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.ServicePack", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto out_unique;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_pack_message_received_cb), NULL);
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.ServicePack", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_pack_application_prepare_action_cb), NULL);
/* use a client to download packages */
client = pk_client_new ();
@@ -775,7 +787,8 @@ main (int argc, char *argv[])
gtk_window_set_icon_name (GTK_WINDOW (main_window), GPK_ICON_SERVICE_PACK);
/* Get the main window quit */
- g_signal_connect_swapped (main_window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (main_window, "delete-event",
+ G_CALLBACK (gpk_pack_delete_event_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "filechooserbutton_exclude"));
filter = gtk_file_filter_new ();
@@ -799,7 +812,7 @@ main (int argc, char *argv[])
g_signal_connect (widget, "clicked", G_CALLBACK (gpk_pack_radio_copy_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_pack_button_close_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_create"));
g_signal_connect (widget, "clicked", G_CALLBACK (gpk_pack_button_create_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
@@ -847,13 +860,12 @@ main (int argc, char *argv[])
gtk_widget_show (main_window);
- /* wait */
- gtk_main ();
+ /* run */
+ g_application_run (application);
out_build:
g_object_unref (builder);
-out_unique:
- g_object_unref (unique_app);
+ g_object_unref (application);
if (settings != NULL)
g_object_unref (settings);
if (control != NULL)
diff --git a/src/gpk-update-icon.c b/src/gpk-update-icon.c
index be1b0a7..e731c15 100644
--- a/src/gpk-update-icon.c
+++ b/src/gpk-update-icon.c
@@ -32,7 +32,6 @@
#include <locale.h>
#include <libnotify/notify.h>
#include <packagekit-glib2/packagekit.h>
-#include <unique/unique.h>
#include "egg-debug.h"
#include "egg-dbus-monitor.h"
@@ -44,6 +43,16 @@
#include "gpk-common.h"
/**
+ * gpk_icon_timed_exit_cb:
+ **/
+static gboolean
+gpk_icon_timed_exit_cb (GApplication *application)
+{
+ g_application_quit (application, 0);
+ return FALSE;
+}
+
+/**
* main:
**/
int
@@ -56,7 +65,7 @@ main (int argc, char *argv[])
GpkFirmware *firmware = NULL;
GpkHardware *hardware = NULL;
GOptionContext *context;
- UniqueApp *unique_app;
+ GApplication *application;
gboolean ret;
guint timer_id = 0;
@@ -104,12 +113,7 @@ main (int argc, char *argv[])
}
/* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.UpdateIcon", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.UpdateIcon", argc, argv);
/* add application specific icons to search path */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -123,21 +127,20 @@ main (int argc, char *argv[])
/* Only timeout if we have specified iton the command line */
if (timed_exit) {
- timer_id = g_timeout_add_seconds (120, (GSourceFunc) gtk_main_quit, NULL);
+ timer_id = g_timeout_add_seconds (120, (GSourceFunc) gpk_icon_timed_exit_cb, application);
#if GLIB_CHECK_VERSION(2,25,8)
g_source_set_name_by_id (timer_id, "[GpkUpdateIcon] timed exit");
#endif
}
- /* wait */
- gtk_main ();
+ /* run */
+ g_application_run (application);
g_object_unref (cupdate);
g_object_unref (watch);
g_object_unref (firmware);
g_object_unref (hardware);
-unique_out:
- g_object_unref (unique_app);
+ g_object_unref (application);
return 0;
}
diff --git a/src/gpk-update-viewer-main.c b/src/gpk-update-viewer-main.c
index 7321ad0..ffed5b5 100644
--- a/src/gpk-update-viewer-main.c
+++ b/src/gpk-update-viewer-main.c
@@ -25,7 +25,6 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include <locale.h>
-#include <unique/unique.h>
#include "egg-debug.h"
@@ -36,19 +35,19 @@
* gpk_update_viewer_close_cb
**/
static void
-gpk_update_viewer_close_cb (GpkUpdateViewer *update_viewer)
+gpk_update_viewer_close_cb (GpkUpdateViewer *update_viewer, GApplication *application)
{
- gtk_main_quit ();
+ g_application_quit (application, 0);
}
/**
- * gpk_update_viewer_message_received_cb
+ * gpk_update_viewer_application_prepare_action_cb:
**/
static void
-gpk_update_viewer_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, GpkUpdateViewer *update_viewer)
+gpk_update_viewer_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, GpkUpdateViewer *update_viewer)
{
- if (command == UNIQUE_ACTIVATE)
- gpk_update_viewer_show (update_viewer);
+ gpk_update_viewer_show (update_viewer);
}
/**
@@ -60,7 +59,7 @@ main (int argc, char *argv[])
gboolean program_version = FALSE;
GpkUpdateViewer *update_viewer = NULL;
GOptionContext *context;
- UniqueApp *unique_app;
+ GApplication *application;
gboolean ret;
const GOptionEntry options[] = {
@@ -104,27 +103,23 @@ main (int argc, char *argv[])
if (!ret)
return 1;
- /* are we already activated? */
- unique_app = unique_app_new ("org.freedesktop.PackageKit.UpdateViewer", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto unique_out;
- }
-
/* create a new update_viewer object */
update_viewer = gpk_update_viewer_new ();
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gpk_update_viewer_message_received_cb), update_viewer);
+
+ /* are we already activated? */
+ application = g_application_new_and_register ("org.freedesktop.PackageKit.UpdateViewer", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gpk_update_viewer_application_prepare_action_cb), update_viewer);
+
+ /* close */
g_signal_connect (update_viewer, "action-close",
- G_CALLBACK (gpk_update_viewer_close_cb), NULL);
+ G_CALLBACK (gpk_update_viewer_close_cb), application);
- /* wait */
- gtk_main ();
+ /* run */
+ g_application_run (application);
g_object_unref (update_viewer);
-unique_out:
- g_object_unref (unique_app);
+ g_object_unref (application);
return 0;
}
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 2a34a7e..a477f5d 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -26,7 +26,6 @@
#include <gdk/gdkkeysyms.h>
#include <packagekit-glib2/packagekit.h>
#include <canberra-gtk.h>
-#include <unique/unique.h>
#include "egg-debug.h"
#include "egg-string.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]