summaryrefslogtreecommitdiff
path: root/mate-dictionary
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-dictionary
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-dictionary')
-rw-r--r--mate-dictionary/src/gdict-pref-dialog.c15
-rw-r--r--mate-dictionary/src/gdict-source-dialog.c49
2 files changed, 32 insertions, 32 deletions
diff --git a/mate-dictionary/src/gdict-pref-dialog.c b/mate-dictionary/src/gdict-pref-dialog.c
index 295cce46..4267761d 100644
--- a/mate-dictionary/src/gdict-pref-dialog.c
+++ b/mate-dictionary/src/gdict-pref-dialog.c
@@ -41,6 +41,7 @@
#include "gdict-common.h"
#define GDICT_PREFERENCES_UI PKGDATADIR "/mate-dictionary-preferences.ui"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (dialog->builder, (x))))
#define DEFAULT_MIN_WIDTH 220
#define DEFAULT_MIN_HEIGHT 330
@@ -690,40 +691,40 @@ gdict_pref_dialog_init (GdictPrefDialog *dialog)
/* the main widget */
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- GTK_WIDGET (gtk_builder_get_object (dialog->builder, "preferences_root")));
+ GET_WIDGET ("preferences_root"));
/* keep all the interesting widgets around */
- dialog->notebook = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "preferences_notebook"));
+ dialog->notebook = GET_WIDGET ("preferences_notebook");
gtk_widget_add_events (dialog->notebook, GDK_SCROLL_MASK);
g_signal_connect (dialog->notebook, "scroll-event",
G_CALLBACK (gdict_dialog_page_scroll_event_cb), GTK_WINDOW (dialog));
- dialog->sources_view = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "sources_treeview"));
+ dialog->sources_view = GET_WIDGET ("sources_treeview");
build_sources_view (dialog);
dialog->active_source = g_settings_get_string (dialog->settings, GDICT_SETTINGS_SOURCE_KEY);
- dialog->sources_add = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "add_button"));
+ dialog->sources_add = GET_WIDGET ("add_button");
gtk_widget_set_tooltip_text (dialog->sources_add,
_("Add a new dictionary source"));
g_signal_connect (dialog->sources_add, "clicked",
G_CALLBACK (source_add_clicked_cb), dialog);
- dialog->sources_remove = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "remove_button"));
+ dialog->sources_remove = GET_WIDGET ("remove_button");
gtk_widget_set_tooltip_text (dialog->sources_remove,
_("Remove the currently selected dictionary source"));
g_signal_connect (dialog->sources_remove, "clicked",
G_CALLBACK (source_remove_clicked_cb), dialog);
- dialog->sources_edit = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "edit_button"));
+ dialog->sources_edit = GET_WIDGET ("edit_button");
gtk_widget_set_tooltip_text (dialog->sources_edit,
_("Edit the currently selected dictionary source"));
g_signal_connect (dialog->sources_edit, "clicked",
G_CALLBACK (source_edit_clicked_cb), dialog);
font = g_settings_get_string (dialog->settings, GDICT_SETTINGS_PRINT_FONT_KEY);
- dialog->font_button = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "print_font_button"));
+ dialog->font_button = GET_WIDGET ("print_font_button");
gtk_font_chooser_set_font (GTK_FONT_CHOOSER (dialog->font_button), font);
gtk_widget_set_tooltip_text (dialog->font_button,
_("Set the font used for printing the definitions"));
diff --git a/mate-dictionary/src/gdict-source-dialog.c b/mate-dictionary/src/gdict-source-dialog.c
index d5dd54d3..444febdd 100644
--- a/mate-dictionary/src/gdict-source-dialog.c
+++ b/mate-dictionary/src/gdict-source-dialog.c
@@ -40,6 +40,8 @@
#include "gdict-common.h"
#define GDICT_SOURCE_UI PKGDATADIR "/mate-dictionary-source.ui"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (dialog->builder, (x))))
+#define GET_EDITABLE(x) (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, (x))))
/*********************
* GdictSourceDialog *
@@ -112,10 +114,10 @@ transport_combo_changed_cb (GtkWidget *widget,
if (transport == GDICT_SOURCE_TRANSPORT_DICTD)
{
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_label")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_entry")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_label")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_entry")));
+ gtk_widget_show (GET_WIDGET ("hostname_label"));
+ gtk_widget_show (GET_WIDGET ("hostname_entry"));
+ gtk_widget_show (GET_WIDGET ("port_label"));
+ gtk_widget_show (GET_WIDGET ("port_entry"));
if (dialog->action == GDICT_SOURCE_DIALOG_CREATE)
{
@@ -126,10 +128,10 @@ transport_combo_changed_cb (GtkWidget *widget,
}
else
{
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_label")));
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_entry")));
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_label")));
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_entry")));
+ gtk_widget_hide (GET_WIDGET ("hostname_label"));
+ gtk_widget_hide (GET_WIDGET ("hostname_entry"));
+ gtk_widget_hide (GET_WIDGET ("port_label"));
+ gtk_widget_hide (GET_WIDGET ("port_entry"));
if (dialog->action == GDICT_SOURCE_DIALOG_CREATE)
{
@@ -147,7 +149,7 @@ get_text_from_entry (GdictSourceDialog *dialog,
GtkWidget *entry;
gchar *retval;
- entry = GTK_WIDGET (gtk_builder_get_object (dialog->builder, entry_name));
+ entry = GET_WIDGET (entry_name);
if (!entry)
return NULL;
@@ -163,7 +165,7 @@ set_text_to_entry (GdictSourceDialog *dialog,
{
GtkWidget *entry;
- entry = GTK_WIDGET (gtk_builder_get_object (dialog->builder, entry_name));
+ entry = GET_WIDGET (entry_name);
if (!entry)
return;
@@ -190,10 +192,10 @@ set_transport_settings (GdictSourceDialog *dialog)
set_text_to_entry (dialog, "hostname_entry", hostname);
set_text_to_entry (dialog, "port_entry", port_str);
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_label")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "hostname_entry")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_label")));
- gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (dialog->builder, "port_entry")));
+ gtk_widget_show (GET_WIDGET ("hostname_label"));
+ gtk_widget_show (GET_WIDGET ("hostname_entry"));
+ gtk_widget_show (GET_WIDGET ("port_label"));
+ gtk_widget_show (GET_WIDGET ("port_entry"));
g_free (port_str);
}
@@ -571,7 +573,6 @@ gdict_source_dialog_constructor (GType type,
{
GObject *object;
GdictSourceDialog *dialog;
- GtkWidget *vbox;
GError *error = NULL;
object = G_OBJECT_CLASS (gdict_source_dialog_parent_class)->constructor (type,
@@ -595,12 +596,12 @@ gdict_source_dialog_constructor (GType type,
/* the main widget */
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- GTK_WIDGET (gtk_builder_get_object (dialog->builder, "source_root")));
+ GET_WIDGET ("source_root"));
/* the transport combo changes the UI by changing the visible widgets
* bound to the transport's own options.
*/
- dialog->transport_combo = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "transport_combo"));
+ dialog->transport_combo = GET_WIDGET ("transport_combo");
g_signal_connect (dialog->transport_combo, "changed",
G_CALLBACK (transport_combo_changed_cb),
dialog);
@@ -610,14 +611,12 @@ gdict_source_dialog_constructor (GType type,
"gtk-help",
GTK_RESPONSE_HELP);
- vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "db-vbox"));
dialog->db_chooser = gdict_database_chooser_new ();
- gtk_box_pack_start (GTK_BOX (vbox), dialog->db_chooser, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("db-vbox")), dialog->db_chooser, TRUE, TRUE, 0);
gtk_widget_show (dialog->db_chooser);
- vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "strat-vbox"));
dialog->strat_chooser = gdict_strategy_chooser_new ();
- gtk_box_pack_start (GTK_BOX (vbox), dialog->strat_chooser, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("strat-vbox")), dialog->strat_chooser, TRUE, TRUE, 0);
gtk_widget_show (dialog->strat_chooser);
/* the UI changes depending on the action that the source dialog
@@ -627,10 +626,10 @@ gdict_source_dialog_constructor (GType type,
{
case GDICT_SOURCE_DIALOG_VIEW:
/* disable every editable widget */
- gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "name_entry")), FALSE);
- gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "description_entry")), FALSE);
- gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "hostname_entry")), FALSE);
- gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "port_entry")), FALSE);
+ gtk_editable_set_editable (GET_EDITABLE ("name_entry"), FALSE);
+ gtk_editable_set_editable (GET_EDITABLE ("description_entry"), FALSE);
+ gtk_editable_set_editable (GET_EDITABLE ("hostname_entry"), FALSE);
+ gtk_editable_set_editable (GET_EDITABLE ("port_entry"), FALSE);
gtk_widget_set_sensitive (dialog->transport_combo, FALSE);