aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-03 14:46:07 +0100
committerThomas White <taw@physics.org>2021-03-03 14:46:07 +0100
commit3861fe8e45e0c4e167e4e301863dd2074961115b (patch)
tree219cb7076ff0af144c6339450cab2c97c5da2437 /src
parent1512e2a654cd2a0edc20e174a26704ca8bd173fa (diff)
Add get_text_or_null
Diffstat (limited to 'src')
-rw-r--r--src/gtk-util-routines.c8
-rw-r--r--src/gtk-util-routines.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/gtk-util-routines.c b/src/gtk-util-routines.c
index a5e04457..83ed066f 100644
--- a/src/gtk-util-routines.c
+++ b/src/gtk-util-routines.c
@@ -118,3 +118,11 @@ void redraw_widget(GtkWidget *wid)
h = gtk_widget_get_allocated_height(GTK_WIDGET(wid));
gtk_widget_queue_draw_area(GTK_WIDGET(wid), 0, 0, w, h);
}
+
+
+const char *get_text_or_null(GtkEntry *entry)
+{
+ const char *text = gtk_entry_get_text(entry);
+ if ( text[0] == '\0' ) return NULL;
+ return text;
+}
diff --git a/src/gtk-util-routines.h b/src/gtk-util-routines.h
index a6722f5a..ee91ad84 100644
--- a/src/gtk-util-routines.h
+++ b/src/gtk-util-routines.h
@@ -39,5 +39,6 @@ extern int i_maybe_disable(GtkWidget *toggle, GtkWidget *widget);
extern int i_maybe_disable_and_deselect(GtkWidget *toggle, GtkWidget *widget);
extern void set_active(GtkWidget *tb, int active);
extern void redraw_widget(GtkWidget *wid);
+extern const char *get_text_or_null(GtkEntry *entry);
#endif