From 3861fe8e45e0c4e167e4e301863dd2074961115b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 3 Mar 2021 14:46:07 +0100 Subject: Add get_text_or_null --- src/gtk-util-routines.c | 8 ++++++++ src/gtk-util-routines.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src') 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 -- cgit v1.2.3