Don't add "Go to last error" to filtering log window's context menu.
authorwwp <wwp@free.fr>
Mon, 23 Apr 2018 16:50:40 +0000 (18:50 +0200)
committerwwp <wwp@free.fr>
Mon, 23 Apr 2018 16:50:40 +0000 (18:50 +0200)
src/common/log.c
src/common/log.h
src/gtk/logwindow.c
src/gtk/logwindow.h

index 103e9f1f16a3af6e73cdb4b6cdea16552929cf5c..8b21061a1db8a2e8a05a9102798fee2a5193295a 100644 (file)
@@ -64,6 +64,12 @@ static gchar *log_filename[LOG_INSTANCE_MAX] = {
        NULL
 };
 
+/* read-only */
+static gchar *log_error_capability[LOG_INSTANCE_MAX] = {
+       TRUE,
+       FALSE
+};
+
 typedef struct _LogInstanceData LogInstanceData;
 
 struct _LogInstanceData {
@@ -178,6 +184,12 @@ void get_log_prefs(LogInstance instance, int** logwin_width, int** logwin_height
                *logwin_height = log_instances[instance].prefs_logwin_height;
 }
 
+gboolean get_log_error_capability(LogInstance instance)
+{
+       return log_error_capability[instance];
+
+}
+
 void log_print(LogInstance instance, const gchar *format, ...)
 {
        va_list args;
index f6819f908225c50efdab894e9342c5b10e0a673d..c48343b7d12bfc22af13fecd04d62b922de725b7 100644 (file)
@@ -67,6 +67,7 @@ void set_log_title(LogInstance instance, gchar *title);
 gchar *get_log_title(LogInstance instance);
 void set_log_prefs(LogInstance instance, int* logwin_width, int* logwin_height);
 void get_log_prefs(LogInstance instance, int** logwin_width, int** logwin_height);
+gboolean get_log_error_capability(LogInstance instance);
 void log_print         (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
 void log_message       (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
 void log_warning       (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
index 56b151fc1ac68f13acb2cf7b6ab4b357a4ff810a..47ff1c891860543bd32456ffa1f9c2849f84cf2f 100644 (file)
@@ -146,6 +146,7 @@ LogWindow *log_window_create(LogInstance instance)
        logwin->scrolledwin = scrolledwin;
        logwin->text = text;
        logwin->hook_id = hooks_register_hook(get_log_hook(instance), log_window_append, logwin);
+       logwin->has_error_capability = get_log_error_capability(instance);
 
        return logwin;
 }
@@ -448,11 +449,13 @@ static void log_window_popup_menu_extend(GtkTextView *textview,
        gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
        gtk_widget_show(menuitem);
 
-       menuitem = gtk_menu_item_new_with_mnemonic(_("_Go to last error"));
-       g_signal_connect(G_OBJECT(menuitem), "activate",
-                        G_CALLBACK(log_window_go_to_last_error), logwin);
-       gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
-       gtk_widget_show(menuitem);
+       if (logwin->has_error_capability) {
+               menuitem = gtk_menu_item_new_with_mnemonic(_("_Go to last error"));
+               g_signal_connect(G_OBJECT(menuitem), "activate",
+                                G_CALLBACK(log_window_go_to_last_error), logwin);
+               gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
+               gtk_widget_show(menuitem);
+       }
 
        menuitem = gtk_menu_item_new_with_mnemonic(_("Clear _Log"));
        g_signal_connect(G_OBJECT(menuitem), "activate",
index 75a7def7a5112219d8f601adf8349b3032dd7740..f47cb2f522f48a1190c0f0ef8b8d822ad336b692 100644 (file)
@@ -51,6 +51,7 @@ struct _LogWindow
        gboolean hidden;
        gboolean never_shown;
        gboolean has_error;
+       gboolean has_error_capability;
 };
 
 LogWindow *log_window_create(LogInstance instance);