summaryrefslogtreecommitdiff
path: root/mate-screenshot
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-02-11 14:01:28 +0100
committerraveit65 <[email protected]>2020-03-09 17:19:32 +0100
commit2f6a5e1b7456fe3accfedd2b5051a96923e3c044 (patch)
tree9d957175da555ba3c3d0d42496add01aedbffca3 /mate-screenshot
parentebae269c7e5eb6a1d57a22ab690bccb87fd494b4 (diff)
downloadmate-utils-2f6a5e1b7456fe3accfedd2b5051a96923e3c044.tar.bz2
mate-utils-2f6a5e1b7456fe3accfedd2b5051a96923e3c044.tar.xz
Define custom macros for wrapping the calls to gtk_builder_get_object
Diffstat (limited to 'mate-screenshot')
-rw-r--r--mate-screenshot/src/screenshot-dialog.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/mate-screenshot/src/screenshot-dialog.c b/mate-screenshot/src/screenshot-dialog.c
index 854ae3e4..66c9cd26 100644
--- a/mate-screenshot/src/screenshot-dialog.c
+++ b/mate-screenshot/src/screenshot-dialog.c
@@ -27,6 +27,8 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (dialog->builder, (x))))
+
enum {
TYPE_IMAGE_PNG,
TYPE_TEXT_URI_LIST,
@@ -42,7 +44,7 @@ static GtkTargetEntry drag_types[] =
struct ScreenshotDialog
{
- GtkBuilder *ui;
+ GtkBuilder *builder;
GdkPixbuf *screenshot;
GdkPixbuf *preview_image;
GtkWidget *save_widget;
@@ -192,11 +194,11 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
dialog = g_new0 (ScreenshotDialog, 1);
- dialog->ui = gtk_builder_new ();
+ dialog->builder = gtk_builder_new ();
dialog->screenshot = screenshot;
- if (gtk_builder_add_from_resource (dialog->ui, "/org/mate/screenshot/mate-screenshot.ui", &error) == 0)
+ if (gtk_builder_add_from_resource (dialog->builder, "/org/mate/screenshot/mate-screenshot.ui", &error) == 0)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, 0,
@@ -211,7 +213,7 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
exit (1);
}
- gtk_builder_set_translation_domain (dialog->ui, GETTEXT_PACKAGE);
+ gtk_builder_set_translation_domain (dialog->builder, GETTEXT_PACKAGE);
width = gdk_pixbuf_get_width (screenshot);
height = gdk_pixbuf_get_height (screenshot);
@@ -219,11 +221,11 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
width /= 5;
height /= 5;
- toplevel = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "toplevel"));
- aspect_frame = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "aspect_frame"));
- preview_darea = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "preview_darea"));
- dialog->filename_entry = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "filename_entry"));
- file_chooser_box = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "file_chooser_box"));
+ toplevel = GET_WIDGET ("toplevel");
+ aspect_frame = GET_WIDGET ("aspect_frame");
+ preview_darea = GET_WIDGET ("preview_darea");
+ dialog->filename_entry = GET_WIDGET ("filename_entry");
+ file_chooser_box = GET_WIDGET ("file_chooser_box");
dialog->save_widget = gtk_file_chooser_button_new (_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog->save_widget), FALSE);
@@ -287,7 +289,7 @@ screenshot_dialog_enable_dnd (ScreenshotDialog *dialog)
g_return_if_fail (dialog != NULL);
- preview_darea = GTK_WIDGET (gtk_builder_get_object (dialog->ui, "preview_darea"));
+ preview_darea = GET_WIDGET ("preview_darea");
gtk_drag_source_set (preview_darea,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
drag_types, G_N_ELEMENTS (drag_types),
@@ -297,7 +299,7 @@ screenshot_dialog_enable_dnd (ScreenshotDialog *dialog)
GtkWidget *
screenshot_dialog_get_toplevel (ScreenshotDialog *dialog)
{
- return GTK_WIDGET (gtk_builder_get_object (dialog->ui, "toplevel"));
+ return GET_WIDGET ("toplevel");
}
char *