summaryrefslogtreecommitdiff
path: root/baobab/src
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 /baobab/src
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 'baobab/src')
-rw-r--r--baobab/src/baobab-prefs.c7
-rw-r--r--baobab/src/baobab-treeview.c8
-rw-r--r--baobab/src/baobab-utils.c18
-rw-r--r--baobab/src/baobab-utils.h2
-rw-r--r--baobab/src/baobab.c64
5 files changed, 39 insertions, 60 deletions
diff --git a/baobab/src/baobab-prefs.c b/baobab/src/baobab-prefs.c
index cdbb92c3..56e37e51 100644
--- a/baobab/src/baobab-prefs.c
+++ b/baobab/src/baobab-prefs.c
@@ -35,6 +35,7 @@
#include "baobab-prefs.h"
#define BAOBAB_PREFERENCES_UI_RESOURCE "/org/mate/disk-usage-analyzer/baobab-dialog-scan-props.ui"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
enum
{
@@ -162,7 +163,7 @@ create_tree_props (GtkBuilder *builder, GtkTreeModel *model)
GtkTreeViewColumn *col;
GtkWidget *tvw;
- tvw = GTK_WIDGET (gtk_builder_get_object (builder , "tree_view_props"));
+ tvw = GET_WIDGET ("tree_view_props");
/* checkbox column */
cell = gtk_cell_renderer_toggle_new ();
@@ -294,7 +295,7 @@ baobab_prefs_dialog (void)
return;
}
- dlg = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_scan_props"));
+ dlg = GET_WIDGET ("dialog_scan_props");
gtk_window_set_transient_for (GTK_WINDOW (dlg),
GTK_WINDOW (baobab.window));
@@ -312,7 +313,7 @@ baobab_prefs_dialog (void)
create_tree_props (builder, GTK_TREE_MODEL (model));
fill_props_model (model);
- check_enablehome = GTK_WIDGET (gtk_builder_get_object (builder, "check_enable_home"));
+ check_enablehome = GET_WIDGET ("check_enable_home");
g_settings_bind (baobab.prefs_settings,
BAOBAB_SETTINGS_MONITOR_HOME,
check_enablehome, "active",
diff --git a/baobab/src/baobab-treeview.c b/baobab/src/baobab-treeview.c
index eb6beb5e..8e5b7839 100644
--- a/baobab/src/baobab-treeview.c
+++ b/baobab/src/baobab-treeview.c
@@ -34,6 +34,8 @@
#include "baobab-utils.h"
#include "callbacks.h"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, (x))))
+
static GtkTreeStore *
create_model (void)
{
@@ -199,9 +201,8 @@ create_directory_treeview (void)
{
GtkCellRenderer *cell;
GtkTreeViewColumn *col;
- GtkWidget *scrolled;
- GtkWidget *tvw = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "treeview1"));
+ GtkWidget *tvw = GET_WIDGET ("treeview1");
g_signal_connect (tvw, "row-expanded",
G_CALLBACK (on_tv_row_expanded), NULL);
@@ -285,8 +286,7 @@ create_directory_treeview (void)
gtk_tree_view_collapse_all (GTK_TREE_VIEW (tvw));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tvw), FALSE);
- scrolled = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "scrolledwindow1"));
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (GET_WIDGET ("scrolledwindow1")),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
diff --git a/baobab/src/baobab-utils.c b/baobab/src/baobab-utils.c
index 022c3a0d..5aaec321 100644
--- a/baobab/src/baobab-utils.c
+++ b/baobab/src/baobab-utils.c
@@ -145,24 +145,6 @@ on_toggled (GtkToggleButton *togglebutton, gpointer dialog)
(GTK_FILE_CHOOSER (dialog)));
}
-void
-set_ui_action_sens (const gchar *name, gboolean sens)
-{
- GtkAction *a;
-
- a = GTK_ACTION (gtk_builder_get_object (baobab.main_ui, name));
- gtk_action_set_sensitive (a, sens);
-}
-
-void
-set_ui_widget_sens (const gchar *name, gboolean sens)
-{
- GtkWidget *w;
-
- w = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, name));
- gtk_widget_set_sensitive (w, sens);
-}
-
gboolean
show_bars (GtkTreeModel *mdl,
GtkTreePath *path,
diff --git a/baobab/src/baobab-utils.h b/baobab/src/baobab-utils.h
index 7ef23987..d47ba798 100644
--- a/baobab/src/baobab-utils.h
+++ b/baobab/src/baobab-utils.h
@@ -40,8 +40,6 @@ void popupmenu_list (GtkTreePath *path, GdkEventButton *event, gboolean can_tras
void open_file_with_application (GFile *file);
gboolean can_trash_file (GFile *file);
gboolean trash_file (GFile *file);
-void set_ui_action_sens (const gchar *name, gboolean sens);
-void set_ui_widget_sens (const gchar *name, gboolean sens);
gboolean baobab_help_display (GtkWindow *parent, const gchar *file_name, const gchar *link_id);
gboolean is_virtual_filesystem (GFile *file);
diff --git a/baobab/src/baobab.c b/baobab/src/baobab.c
index 84e02182..4ad034ed 100644
--- a/baobab/src/baobab.c
+++ b/baobab/src/baobab.c
@@ -38,6 +38,9 @@
#include "baobab-ringschart.h"
#define BAOBAB_UI_RESOURCE "/org/mate/disk-usage-analyzer/baobab-main-window.ui"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, (x))))
+#define GET_ACTION(x) (GTK_ACTION (gtk_builder_get_object (baobab.main_ui, (x))))
+#define GET_TOGGLE_ACTION(x) (GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, (x))))
static void push_iter_in_stack (GtkTreeIter *);
static GtkTreeIter pop_iter_from_stack (void);
@@ -137,27 +140,27 @@ check_menu_sens (gboolean scanning)
gtk_main_iteration ();
baobab_set_statusbar (_("Scanning..."));
- set_ui_action_sens ("expand_all", TRUE);
- set_ui_action_sens ("collapse_all", TRUE);
+ gtk_action_set_sensitive (GET_ACTION ("expand_all"), TRUE);
+ gtk_action_set_sensitive (GET_ACTION ("collapse_all"), TRUE);
}
has_current_location = baobab.current_location != NULL;
- set_ui_action_sens ("menuscanhome", !scanning);
- set_ui_action_sens ("menuallfs", !scanning);
- set_ui_action_sens ("menuscandir", !scanning);
- set_ui_action_sens ("menustop", scanning);
- set_ui_action_sens ("menurescan", !scanning && has_current_location);
- set_ui_action_sens ("preferenze1", !scanning);
- set_ui_action_sens ("menu_scan_rem", !scanning);
- set_ui_action_sens ("ck_allocated", !scanning && baobab.is_local);
-
- set_ui_widget_sens ("tbscanhome", !scanning);
- set_ui_widget_sens ("tbscanall", !scanning);
- set_ui_widget_sens ("tbscandir", !scanning);
- set_ui_widget_sens ("tbstop", scanning);
- set_ui_widget_sens ("tbrescan", !scanning && has_current_location);
- set_ui_widget_sens ("tb_scan_remote", !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menuscanhome"), !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menuallfs"), !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menuscandir"), !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menustop"), scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menurescan"), !scanning && has_current_location);
+ gtk_action_set_sensitive (GET_ACTION ("preferenze1"), !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("menu_scan_rem"), !scanning);
+ gtk_action_set_sensitive (GET_ACTION ("ck_allocated"), !scanning && baobab.is_local);
+
+ gtk_widget_set_sensitive (GET_WIDGET ("tbscanhome"), !scanning);
+ gtk_widget_set_sensitive (GET_WIDGET ("tbscanall"), !scanning);
+ gtk_widget_set_sensitive (GET_WIDGET ("tbscandir"), !scanning);
+ gtk_widget_set_sensitive (GET_WIDGET ("tbstop"), scanning);
+ gtk_widget_set_sensitive (GET_WIDGET ("tbrescan"), !scanning && has_current_location);
+ gtk_widget_set_sensitive (GET_WIDGET ("tb_scan_remote"), !scanning);
}
static void
@@ -174,7 +177,6 @@ update_scan_label (void)
gchar *total;
gchar *used;
gchar *available;
- GtkWidget *label;
total = g_format_size (baobab.fs.total);
used = g_format_size (baobab.fs.used);
@@ -190,9 +192,7 @@ update_scan_label (void)
g_free (used);
g_free (available);
- label = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "label1"));
-
- gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_label_set_markup (GTK_LABEL (GET_WIDGET ("label1")), markup);
g_free (markup);
}
@@ -228,7 +228,7 @@ baobab_scan_location (GFile *file)
/* check if the file system is local or remote */
baobab.is_local = scan_is_local (file);
- ck_allocated = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "ck_allocated"));
+ ck_allocated = GET_TOGGLE_ACTION ("ck_allocated");
if (!baobab.is_local) {
gtk_toggle_action_set_active (ck_allocated, FALSE);
gtk_action_set_sensitive (GTK_ACTION (ck_allocated), FALSE);
@@ -649,7 +649,7 @@ baobab_create_toolbar (void)
GtkToolItem *item;
GtkToolItem *separator;
- toolbar = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "toolbar1"));
+ toolbar = GET_WIDGET ("toolbar1");
if (toolbar == NULL) {
g_printerr ("Could not build toolbar\n");
return;
@@ -679,7 +679,7 @@ baobab_create_toolbar (void)
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (baobab.ui_settings,
BAOBAB_SETTINGS_TOOLBAR_VISIBLE,
- GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_tb")), "active",
+ GET_TOGGLE_ACTION ("view_tb"), "active",
G_SETTINGS_BIND_DEFAULT);
}
@@ -687,8 +687,7 @@ baobab_create_toolbar (void)
static void
baobab_create_statusbar (void)
{
- baobab.statusbar = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui,
- "statusbar1"));
+ baobab.statusbar = GET_WIDGET ("statusbar1");
if (baobab.statusbar == NULL) {
g_printerr ("Could not build statusbar\n");
return;
@@ -700,7 +699,7 @@ baobab_create_statusbar (void)
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (baobab.ui_settings,
BAOBAB_SETTINGS_STATUSBAR_VISIBLE,
- GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_sb")), "active",
+ GET_TOGGLE_ACTION ("view_sb"), "active",
G_SETTINGS_BIND_DEFAULT);
}
@@ -1103,7 +1102,7 @@ initialize_charts (void)
gtk_frame_set_label_align (GTK_FRAME (baobab.chart_frame), 0.0, 0.0);
gtk_frame_set_shadow_type (GTK_FRAME (baobab.chart_frame), GTK_SHADOW_IN);
- hpaned_main = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hpaned_main"));
+ hpaned_main = GET_WIDGET ("hpaned_main");
gtk_paned_pack2 (GTK_PANED (hpaned_main),
baobab.chart_frame, TRUE, TRUE);
gtk_paned_set_position (GTK_PANED (hpaned_main), 480);
@@ -1118,7 +1117,7 @@ initialize_charts (void)
"changed",
G_CALLBACK (on_chart_type_change), NULL);
- hbox1 = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hbox1"));
+ hbox1 = GET_WIDGET ("hbox1");
gtk_container_add (GTK_CONTAINER (hbox1), baobab.chart_type_combo);
gtk_box_set_spacing (GTK_BOX (hbox1), 50);
gtk_box_set_child_packing (GTK_BOX (hbox1),
@@ -1282,17 +1281,16 @@ main (int argc, char *argv[])
check_menu_sens (FALSE);
update_scan_label ();
- baobab.window = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "baobab_window"));
+ baobab.window = GET_WIDGET ("baobab_window");
gtk_window_set_position (GTK_WINDOW (baobab.window),
GTK_WIN_POS_CENTER);
baobab.tree_view = create_directory_treeview ();
- set_ui_action_sens ("menurescan", FALSE);
+ gtk_action_set_sensitive (GET_ACTION ("menurescan"), FALSE);
/* set allocated space checkbox */
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui,
- "ck_allocated")),
+ gtk_toggle_action_set_active (GET_TOGGLE_ACTION ("ck_allocated"),
baobab.show_allocated);
gtk_widget_show (baobab.window);