[gnome-screenshot/wip/exalm/cleanups: 1/16] dialog: Add functions for retrieving dialog and filename entry



commit 386e6114c43d66eba82cb75115eb1b928e66b057
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Apr 3 03:58:06 2020 +0500

    dialog: Add functions for retrieving dialog and filename entry
    
    This is the first step in making the dialog a GObject. This will allow to
    stop exposing the struct fields publicly.

 src/screenshot-application.c |  8 ++++----
 src/screenshot-dialog.c      | 12 ++++++++++++
 src/screenshot-dialog.h      |  2 ++
 3 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index 38d801d..54a2afd 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -104,7 +104,7 @@ screenshot_close_interactive_dialog (ScreenshotApplication *self)
 {
   ScreenshotDialog *dialog = self->priv->dialog;
   save_folder_to_settings (self);
-  gtk_widget_destroy (dialog->dialog);
+  gtk_widget_destroy (screenshot_dialog_get_dialog (dialog));
   g_free (dialog);
 }
 
@@ -143,7 +143,7 @@ save_pixbuf_handle_error (ScreenshotApplication *self,
           g_autofree gchar *detail = g_strdup_printf (_("A file named ā€œ%sā€ already exists in ā€œ%sā€"),
                                                       file_name, folder_name);
 
-          gint response = screenshot_show_dialog (GTK_WINDOW (dialog->dialog),
+          gint response = screenshot_show_dialog (GTK_WINDOW (screenshot_dialog_get_dialog (dialog)),
                                                   GTK_MESSAGE_WARNING,
                                                   GTK_BUTTONS_YES_NO,
                                                   _("Overwrite existing file?"),
@@ -159,14 +159,14 @@ save_pixbuf_handle_error (ScreenshotApplication *self,
         }
       else
         {
-          screenshot_show_dialog (GTK_WINDOW (dialog->dialog),
+          screenshot_show_dialog (GTK_WINDOW (screenshot_dialog_get_dialog (dialog)),
                                   GTK_MESSAGE_ERROR,
                                   GTK_BUTTONS_OK,
                                   _("Unable to capture a screenshot"),
                                   _("Error creating file. Please choose another location and retry."));
         }
 
-      gtk_widget_grab_focus (dialog->filename_entry);
+      gtk_widget_grab_focus (screenshot_dialog_get_filename_entry (dialog));
     }
   else
     {
diff --git a/src/screenshot-dialog.c b/src/screenshot-dialog.c
index 3d7e83f..141a86a 100644
--- a/src/screenshot-dialog.c
+++ b/src/screenshot-dialog.c
@@ -324,3 +324,15 @@ screenshot_dialog_set_busy (ScreenshotDialog *dialog,
 
   gdk_flush ();
 }
+
+GtkWidget *
+screenshot_dialog_get_dialog (ScreenshotDialog *dialog)
+{
+  return dialog->dialog;
+}
+
+GtkWidget *
+screenshot_dialog_get_filename_entry (ScreenshotDialog *dialog)
+{
+  return dialog->filename_entry;
+}
diff --git a/src/screenshot-dialog.h b/src/screenshot-dialog.h
index 50b32a7..65e0aab 100644
--- a/src/screenshot-dialog.h
+++ b/src/screenshot-dialog.h
@@ -58,3 +58,5 @@ char             *screenshot_dialog_get_folder   (ScreenshotDialog *dialog);
 char             *screenshot_dialog_get_filename (ScreenshotDialog *dialog);
 void              screenshot_dialog_set_busy     (ScreenshotDialog *dialog,
                                                   gboolean          busy);
+GtkWidget        *screenshot_dialog_get_dialog   (ScreenshotDialog *dialog);
+GtkWidget        *screenshot_dialog_get_filename_entry (ScreenshotDialog *dialog);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]