summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-06-01 12:08:11 +0200
committerraveit65 <[email protected]>2020-06-20 17:10:49 +0200
commita069f15771790694de54e56d9d22d8e81cf45515 (patch)
tree7660e8830d84073a5159e3cb200cc0e835058257
parentd3e763f5db20ae615506fbceb4df8d5fa2707413 (diff)
downloadmate-calc-a069f15771790694de54e56d9d22d8e81cf45515.tar.bz2
mate-calc-a069f15771790694de54e56d9d22d8e81cf45515.tar.xz
math-history-entry: Reduce the macro scope and its argument number
-rw-r--r--src/math-history-entry.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/math-history-entry.c b/src/math-history-entry.c
index 0d8940a..8a6b4ae 100644
--- a/src/math-history-entry.c
+++ b/src/math-history-entry.c
@@ -27,8 +27,6 @@ struct MathHistoryEntryPrivate
G_DEFINE_TYPE_WITH_PRIVATE (MathHistoryEntry, math_history_entry, GTK_TYPE_LIST_BOX_ROW);
#define UI_HISTORY_ENTRY_RESOURCE_PATH "/org/mate/calculator/ui/history-entry.ui"
-#define GET_WIDGET(ui, name) \
- GTK_WIDGET(gtk_builder_get_object(ui, name))
MathHistoryEntry *
math_history_entry_new(MathEquation *equation)
@@ -63,6 +61,8 @@ equation_clicked_cb (GtkWidget *widget, GdkEventButton *eventbutton, MathHistory
void
math_history_entry_insert_entry(MathHistoryEntry *history_entry, const gchar *equation, const gchar *answer_four_digits, const gchar *answer_nine_digits)
{
+ #define get_widget(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
GtkBuilder *builder = NULL;
GtkWidget *grid;
GError *error = NULL;
@@ -74,16 +74,18 @@ math_history_entry_insert_entry(MathHistoryEntry *history_entry, const gchar *eq
g_clear_error(&error);
return;
}
- grid = GET_WIDGET(builder, "grid");
+ grid = get_widget("grid");
gtk_container_add(GTK_CONTAINER(history_entry), grid);
- history_entry->priv->equation_label = GET_WIDGET(builder, "equation_label");
- history_entry->priv->answer_label = GET_WIDGET(builder, "answer_label");
+ history_entry->priv->equation_label = get_widget("equation_label");
+ history_entry->priv->answer_label = get_widget("answer_label");
gtk_widget_set_tooltip_text(history_entry->priv->equation_label, equation);
gtk_widget_set_tooltip_text(history_entry->priv->answer_label, answer_nine_digits);
gtk_label_set_text(GTK_LABEL(history_entry->priv->equation_label), equation);
gtk_label_set_text(GTK_LABEL(history_entry->priv->answer_label), answer_four_digits);
gtk_builder_connect_signals(builder, history_entry);
g_object_unref(builder);
+
+ #undef get_widget
}
static void