[gnome-packagekit] Add --parent-window options to the client tools so they are set transient in gpk-application
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-packagekit] Add --parent-window options to the client tools so they are set transient in gpk-application
- Date: Wed, 1 Jul 2009 10:53:50 +0000 (UTC)
commit 9acdb6820cd01e73fc863a58c384446c62b99a85
Author: Richard Hughes <richard hughsie com>
Date: Wed Jul 1 11:01:57 2009 +0100
Add --parent-window options to the client tools so they are set transient in gpk-application
src/gpk-application.c | 29 +++++++++++++++++++++++++----
src/gpk-common.c | 23 +++++++++++++++++++++++
src/gpk-common.h | 2 ++
src/gpk-log.c | 11 +++++++++++
src/gpk-prefs.c | 10 ++++++++++
src/gpk-repo.c | 10 ++++++++++
6 files changed, 81 insertions(+), 4 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 5cb1958..0c6f11e 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <gdk/gdkx.h>
#include <gconf/gconf-client.h>
#include <math.h>
#include <string.h>
@@ -2365,13 +2366,23 @@ static void
gpk_application_menu_sources_cb (GtkAction *action, GpkApplication *application)
{
gboolean ret;
+ guint xid;
+ gchar *command;
+ GtkWidget *window;
g_return_if_fail (PK_IS_APPLICATION (application));
- ret = g_spawn_command_line_async ("gpk-repo", NULL);
+ /* get xid */
+ window = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "window_manager"));
+ xid = gdk_x11_drawable_get_xid (gtk_widget_get_window (window));
+
+ command = g_strdup_printf ("%s/gpk-repo --parent-window %u", BINDIR, xid);
+ egg_debug ("running: %s", command);
+ ret = g_spawn_command_line_async (command, NULL);
if (!ret) {
- egg_warning ("spawn of pk-repo failed");
+ egg_warning ("spawn of %s failed", command);
}
+ g_free (command);
}
/**
@@ -2381,13 +2392,23 @@ static void
gpk_application_menu_log_cb (GtkAction *action, GpkApplication *application)
{
gboolean ret;
+ guint xid;
+ gchar *command;
+ GtkWidget *window;
g_return_if_fail (PK_IS_APPLICATION (application));
- ret = g_spawn_command_line_async ("gpk-log", NULL);
+ /* get xid */
+ window = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "window_manager"));
+ xid = gdk_x11_drawable_get_xid (gtk_widget_get_window (window));
+
+ command = g_strdup_printf ("%s/gpk-log --parent-window %u", BINDIR, xid);
+ egg_debug ("running: %s", command);
+ ret = g_spawn_command_line_async (command, NULL);
if (!ret) {
- egg_warning ("spawn of pk-log failed");
+ egg_warning ("spawn of %s failed", command);
}
+ g_free (command);
}
/**
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 57c6942..c226419 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -249,6 +249,29 @@ out:
}
/**
+ * gpk_window_set_parent_xid:
+ **/
+gboolean
+gpk_window_set_parent_xid (GtkWindow *window, guint32 xid)
+{
+ GdkDisplay *display;
+ GdkWindow *parent_window;
+ GdkWindow *our_window;
+
+ g_return_val_if_fail (xid != 0, FALSE);
+
+ display = gdk_display_get_default ();
+ parent_window = gdk_window_foreign_new_for_display (display, xid);
+ our_window = gtk_widget_get_window (GTK_WIDGET (window));
+
+ /* set this above our parent */
+ gtk_window_set_modal (window, TRUE);
+ gdk_window_set_transient_for (our_window, parent_window);
+ return TRUE;
+}
+
+
+/**
* gpk_package_id_format_twoline:
*
* Return value: "<b>GTK Toolkit</b>\ngtk2-2.12.2 (i386)"
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 35eb5e3..37b636e 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -107,6 +107,8 @@ gboolean gpk_window_set_size_request (GtkWindow *window,
guint height);
gboolean gpk_ignore_session_error (GError *error);
gboolean gpk_window_get_small_form_factor_mode (void);
+gboolean gpk_window_set_parent_xid (GtkWindow *window,
+ guint32 xid);
#if (!PK_CHECK_VERSION(0,5,0))
gboolean gpk_error_code_is_need_untrusted (PkErrorCodeEnum error_code);
#endif
diff --git a/src/gpk-log.c b/src/gpk-log.c
index a5b55de..0ad25d4 100644
--- a/src/gpk-log.c
+++ b/src/gpk-log.c
@@ -638,6 +638,7 @@ main (int argc, char *argv[])
UniqueApp *unique_app;
gboolean ret;
guint retval;
+ guint xid = 0;
GError *error = NULL;
const GOptionEntry options[] = {
@@ -646,6 +647,9 @@ main (int argc, char *argv[])
{ "filter", 'f', 0, G_OPTION_ARG_STRING, &filter,
/* TRANSLATORS: preset the GtktextBox with this filter text */
N_("Set the filter to this value"), NULL },
+ { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
+ /* TRANSLATORS: we can make this modal (stay on top of) another window */
+ _("Set the parent window to make this modal"), NULL },
{ NULL}
};
@@ -778,6 +782,13 @@ main (int argc, char *argv[])
/* show */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_simple"));
gtk_widget_show (widget);
+
+ /* set the parent window if it is specified */
+ if (xid != 0) {
+ egg_debug ("Setting xid %i", xid);
+ gpk_window_set_parent_xid (GTK_WINDOW (widget), xid);
+ }
+
gtk_main ();
out_build:
diff --git a/src/gpk-prefs.c b/src/gpk-prefs.c
index 1fd7d1f..75c0f00 100644
--- a/src/gpk-prefs.c
+++ b/src/gpk-prefs.c
@@ -392,6 +392,7 @@ main (int argc, char *argv[])
UniqueApp *unique_app;
PkNetworkEnum state;
guint retval;
+ guint xid = 0;
GError *error = NULL;
const GOptionEntry options[] = {
@@ -399,6 +400,9 @@ main (int argc, char *argv[])
_("Show extra debugging information"), NULL },
{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
_("Show the program version and exit"), NULL },
+ { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
+ /* TRANSLATORS: we can make this modal (stay on top of) another window */
+ _("Set the parent window to make this modal"), NULL },
{ NULL}
};
@@ -493,6 +497,12 @@ main (int argc, char *argv[])
gtk_widget_show (main_window);
+ /* set the parent window if it is specified */
+ if (xid != 0) {
+ egg_debug ("Setting xid %i", xid);
+ gpk_window_set_parent_xid (GTK_WINDOW (main_window), xid);
+ }
+
/* wait */
gtk_main ();
diff --git a/src/gpk-repo.c b/src/gpk-repo.c
index f5ca4e4..d5943f1 100644
--- a/src/gpk-repo.c
+++ b/src/gpk-repo.c
@@ -422,12 +422,16 @@ main (int argc, char *argv[])
UniqueApp *unique_app;
GError *error = NULL;
guint retval;
+ guint xid = 0;
gboolean ret;
GtkBox *box;
const GOptionEntry options[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
_("Show extra debugging information"), NULL },
+ { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
+ /* TRANSLATORS: we can make this modal (stay on top of) another window */
+ _("Set the parent window to make this modal"), NULL },
{ NULL}
};
@@ -542,6 +546,12 @@ main (int argc, char *argv[])
/* show window */
gtk_widget_show (main_window);
+ /* set the parent window if it is specified */
+ if (xid != 0) {
+ egg_debug ("Setting xid %i", xid);
+ gpk_window_set_parent_xid (GTK_WINDOW (main_window), xid);
+ }
+
/* focus back to the close button */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
gtk_widget_grab_focus (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]