[xdg-desktop-portal-gnome/gbsneto/screenshot-portal-v3: 1/3] screenshotdialog: Factor out function




commit 1f1312e3d4a726bf182218ce42797180b6dc1ebc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Aug 5 19:48:08 2022 -0300

    screenshotdialog: Factor out function
    
    The same code is repeated 3 times, so factor them out into a single
    function. Future commits will increment this function to maybe
    avoid the screenshot dialog altogether in some circumstances.

 src/screenshotdialog.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/screenshotdialog.c b/src/screenshotdialog.c
index 6dd6790..665994b 100644
--- a/src/screenshotdialog.c
+++ b/src/screenshotdialog.c
@@ -136,6 +136,14 @@ show_screenshot (ScreenshotDialog *dialog,
   gtk_stack_set_visible_child_name (GTK_STACK (dialog->header_stack), "screenshot");
 }
 
+static void
+maybe_show_screenshot (ScreenshotDialog *dialog,
+                       const char       *filename)
+{
+  show_screenshot (dialog, filename);
+  gtk_widget_show (GTK_WIDGET (dialog));
+}
+
 static void
 screenshot_done (GObject *source,
                  GAsyncResult *result,
@@ -156,8 +164,7 @@ screenshot_done (GObject *source,
       return;
     }
 
-  show_screenshot (dialog, filename);
-  gtk_widget_show (GTK_WIDGET (dialog));
+  maybe_show_screenshot (dialog, filename);
 }
 
 static void
@@ -180,8 +187,7 @@ screenshot_window_done (GObject *source,
       return;
     }
 
-  show_screenshot (dialog, filename);
-  gtk_widget_show (GTK_WIDGET (dialog));
+  maybe_show_screenshot (dialog, filename);
 }
 
 static void
@@ -204,8 +210,7 @@ screenshot_area_done (GObject *source,
       return;
     }
 
-  show_screenshot (dialog, filename);
-  gtk_widget_show (GTK_WIDGET (dialog));
+  maybe_show_screenshot (dialog, filename);
 }
 
 


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