mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Show a "No Events" label when there are no events in the filter dialog
Uses profile.c:evn_foreach() to retrieve the number of events, which if zero, no table is added in the dialog and the label is added instead. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
31b2a6ffa8
commit
aa5f1f0ce2
3 changed files with 11 additions and 6 deletions
2
dive.h
2
dive.h
|
@ -581,7 +581,7 @@ extern void add_people(const char *string);
|
||||||
extern void add_location(const char *string);
|
extern void add_location(const char *string);
|
||||||
extern void add_suit(const char *string);
|
extern void add_suit(const char *string);
|
||||||
extern void remember_event(const char *eventname);
|
extern void remember_event(const char *eventname);
|
||||||
extern void evn_foreach(void (*callback)(const char *, int *, void *), void *data);
|
extern int evn_foreach(void (*callback)(const char *, int *, void *), void *data);
|
||||||
extern void clear_events(void);
|
extern void clear_events(void);
|
||||||
|
|
||||||
extern int add_new_dive(struct dive *dive);
|
extern int add_new_dive(struct dive *dive);
|
||||||
|
|
10
gtk-gui.c
10
gtk-gui.c
|
@ -952,7 +952,7 @@ static void create_toggle(const char* label, int *on, void *_data)
|
||||||
static void selectevents_dialog(GtkWidget *w, gpointer data)
|
static void selectevents_dialog(GtkWidget *w, gpointer data)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
GtkWidget *dialog, *frame, *vbox, *table;
|
GtkWidget *dialog, *frame, *vbox, *table, *label;
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons(_("Select Events"),
|
dialog = gtk_dialog_new_with_buttons(_("Select Events"),
|
||||||
GTK_WINDOW(main_window),
|
GTK_WINDOW(main_window),
|
||||||
|
@ -968,9 +968,13 @@ static void selectevents_dialog(GtkWidget *w, gpointer data)
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
|
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
|
||||||
|
|
||||||
table = gtk_table_new(1, 4, TRUE);
|
table = gtk_table_new(1, 4, TRUE);
|
||||||
|
if (!evn_foreach(&create_toggle, table)) {
|
||||||
|
g_object_ref_sink(G_OBJECT(table));
|
||||||
|
label = gtk_label_new(_("\nNo Events\n"));
|
||||||
|
gtk_container_add(GTK_CONTAINER(frame), label);
|
||||||
|
} else {
|
||||||
gtk_container_add(GTK_CONTAINER(frame), table);
|
gtk_container_add(GTK_CONTAINER(frame), table);
|
||||||
|
}
|
||||||
evn_foreach(&create_toggle, table);
|
|
||||||
|
|
||||||
gtk_widget_show_all(dialog);
|
gtk_widget_show_all(dialog);
|
||||||
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
|
|
@ -303,7 +303,7 @@ static struct ev_select *ev_namelist;
|
||||||
static int evn_allocated;
|
static int evn_allocated;
|
||||||
static int evn_used;
|
static int evn_used;
|
||||||
|
|
||||||
void evn_foreach(void (*callback)(const char *, int *, void *), void *data)
|
int evn_foreach(void (*callback)(const char *, int *, void *), void *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -311,6 +311,7 @@ void evn_foreach(void (*callback)(const char *, int *, void *), void *data)
|
||||||
/* here we display an event name on screen - so translate */
|
/* here we display an event name on screen - so translate */
|
||||||
callback(_(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
|
callback(_(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
|
||||||
}
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_events(void)
|
void clear_events(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue