[Xfce4-commits] <thunar:master> Make the parent passd to thunar_dialogs_show_rename_file() a gpointer.

Jannis Pohlmann noreply at xfce.org
Mon Oct 18 14:10:02 CEST 2010


Updating branch refs/heads/master
         to ad739c46f8e0b06c1cfefb1117ed8c870de9ff12 (commit)
       from 2fa12015b819a4731284d049575ceea869532302 (commit)

commit ad739c46f8e0b06c1cfefb1117ed8c870de9ff12
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Oct 18 14:05:53 2010 +0200

    Make the parent passd to thunar_dialogs_show_rename_file() a gpointer.
    
    This way we can pass a GdkScreen object to it as well as a GtkWindow,
    just like we when calling some of the other dialog routines.

 thunar/thunar-dialogs.c |   19 +++++++++++++++----
 thunar/thunar-dialogs.h |    2 +-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c
index c1a397a..63440c9 100644
--- a/thunar/thunar-dialogs.c
+++ b/thunar/thunar-dialogs.c
@@ -45,7 +45,9 @@
 
 /**
  * thunar_dialogs_show_rename_file:
- * @parent : the parent #GtkWindow.
+ * @parent : a #GtkWidget on which the error dialog should be shown, or a #GdkScreen
+ *           if no #GtkWidget is known. May also be %NULL, in which case the default
+ *           #GdkScreen will be used.
  * @file   : the #ThunarFile we're going to rename.
  *
  * Displays the Thunar rename dialog for a single file rename.
@@ -54,7 +56,7 @@
  *               %NULL if there was no renaming required.
  **/
 ThunarJob *
-thunar_dialogs_show_rename_file (GtkWindow *parent,
+thunar_dialogs_show_rename_file (gpointer    parent,
                                  ThunarFile *file)
 {
   ThunarIconFactory *icon_factory;
@@ -67,21 +69,26 @@ thunar_dialogs_show_rename_file (GtkWindow *parent,
   GtkWidget         *label;
   GtkWidget         *image;
   GtkWidget         *table;
+  GtkWindow         *window;
   GdkPixbuf         *icon;
+  GdkScreen         *screen;
   glong              offset;
   gchar             *title;
   gint               response;
 
-  _thunar_return_val_if_fail (GTK_IS_WINDOW (parent), FALSE);
+  _thunar_return_val_if_fail (window == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WINDOW (parent), FALSE);
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
 
+  /* parse the parent window and screen */
+  screen = thunar_util_parse_parent (parent, &window);
+
   /* get the filename of the file */
   filename = thunar_file_get_display_name (file);
 
   /* create a new dialog window */
   title = g_strdup_printf (_("Rename \"%s\""), filename);
   dialog = gtk_dialog_new_with_buttons (title,
-                                        GTK_WINDOW (parent),
+                                        window,
                                         GTK_DIALOG_MODAL
                                         | GTK_DIALOG_NO_SEPARATOR
                                         | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -92,6 +99,10 @@ thunar_dialogs_show_rename_file (GtkWindow *parent,
   gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
   g_free (title);
 
+  /* move the dialog to the appropriate screen */
+  if (G_UNLIKELY (window == NULL && screen != NULL))
+    gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+
   table = g_object_new (GTK_TYPE_TABLE, "border-width", 6, "column-spacing", 6, "row-spacing", 3, NULL);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);
   gtk_widget_show (table);
diff --git a/thunar/thunar-dialogs.h b/thunar/thunar-dialogs.h
index 67a4f74..b8b82c0 100644
--- a/thunar/thunar-dialogs.h
+++ b/thunar/thunar-dialogs.h
@@ -26,7 +26,7 @@
 
 G_BEGIN_DECLS;
 
-ThunarJob         *thunar_dialogs_show_rename_file     (GtkWindow            *parent,
+ThunarJob         *thunar_dialogs_show_rename_file     (gpointer              parent,
                                                         ThunarFile           *file);
 
 void               thunar_dialogs_show_about           (GtkWindow            *parent,



More information about the Xfce4-commits mailing list