<entry>--debug[=<level>]</entry>\r
<entry>Turn on debugging output (when compiled with Debug enabled). <level> is 0 to 4.</entry>\r
</row>\r
+ <row>\r
+ <entry>-g:<regexp></entry>\r
+ <entry>--grep:<regexp></entry>\r
+ <entry>Filter debug output with regular expression</entry>\r
+ </row>\r
+ <row>\r
+ <entry>+w</entry>\r
+ <entry>--show-log-window</entry>\r
+ <entry>Display log window</entry>\r
+ </row>\r
+ <row>\r
+ <entry>-o:<file></entry>\r
+ <entry>--log-file:<file></entry>\r
+ <entry>Save log data to file</entry>\r
+ </row>\r
<row>\r
<entry />\r
<entry>--alternate</entry>\r
#include "ui_fileops.h"
#include <glib/gprintf.h>
+#include <regex.h>
/*
* Logging functions
*/
+static gchar *regexp = NULL;
+
+void set_regexp(gchar *cmd_regexp)
+{
+ regexp = g_strdup(cmd_regexp);
+}
+
+gchar *get_regexp()
+{
+ return g_strdup(regexp);
+}
static gboolean log_msg_cb(gpointer data)
{
{
va_list ap;
gchar *buf;
+ regex_t regex;
+ gint ret_comp, ret_exec;
+ gchar *filtered_buf;
va_start(ap, format);
buf = g_strdup_vprintf(format, ap);
va_end(ap);
- print_term(buf);
- if (strcmp(domain, DOMAIN_INFO) == 0)
- g_idle_add(log_normal_cb, buf);
+ if (regexp && command_line && buf)
+ {
+ if (g_strcmp0(buf,"\n"))
+ {
+ ret_comp = regcomp(®ex, regexp, 0);
+ if (!ret_comp)
+ {
+ ret_exec = regexec(®ex, buf, 0, NULL, 0);
+
+ filtered_buf = g_strconcat(buf, "\n", NULL);
+ if (!ret_exec)
+ {
+ print_term(filtered_buf);
+ if (strcmp(domain, DOMAIN_INFO) == 0)
+ g_idle_add(log_normal_cb, filtered_buf);
+ else
+ g_idle_add(log_msg_cb, filtered_buf);
+ }
+ regfree(®ex);
+ }
+ }
+ }
else
- g_idle_add(log_msg_cb, buf);
-
+ {
+ print_term(buf);
+ if (strcmp(domain, DOMAIN_INFO) == 0)
+ g_idle_add(log_normal_cb, buf);
+ else
+ g_idle_add(log_msg_cb, buf);
+ }
}
/*
#define DEBUG_LEVEL_MIN 0
#define DEBUG_LEVEL_MAX 4
+void set_regexp(gchar *regexp);
+gchar *get_regexp();
gint get_debug_level(void);
void set_debug_level(gint new_level);
void debug_level_add(gint delta);
#include "layout_config.h"
#include "layout_image.h"
#include "layout_util.h"
+#include "logwindow.h"
#include "menu.h"
#include "pixbuf-renderer.h"
#include "pixbuf_util.h"
return TRUE;
}
+gboolean layout_geometry_get_log_window(LayoutWindow *lw, gint *x, gint *y,
+ gint *w, gint *h)
+{
+ GdkWindow *window;
+
+ if (!layout_valid(&lw)) return FALSE;
+
+ if (!lw->log_window)
+ {
+ return FALSE;
+ }
+
+ window = gtk_widget_get_window(lw->log_window);
+ gdk_window_get_root_origin(window, x, y);
+ *w = gdk_window_get_width(window);
+ *h = gdk_window_get_height(window);
+
+ return TRUE;
+}
+
static void layout_tools_geometry_sync(LayoutWindow *lw)
{
layout_geometry_get_tools(lw, &lw->options.float_window.x, &lw->options.float_window.y,
g_free(lw->options.last_path);
lw->options.last_path = g_strdup(layout_get_path(lw));
+
+ layout_geometry_get_log_window(lw, &lw->options.log_window.x, &lw->options.log_window.y,
+ &lw->options.log_window.w, &lw->options.log_window.h);
+
}
void layout_apply_options(LayoutWindow *lw, LayoutOptions *lop)
WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel);
WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_mode);
+ WRITE_NL(); WRITE_INT(*layout, log_window.x);
+ WRITE_NL(); WRITE_INT(*layout, log_window.y);
+ WRITE_NL(); WRITE_INT(*layout, log_window.w);
+ WRITE_NL(); WRITE_INT(*layout, log_window.h);
+ WRITE_SEPARATOR();
+
WRITE_NL(); WRITE_BOOL(*layout, animate);
}
if (READ_INT(*layout, image_overlay.histogram_channel)) continue;
if (READ_INT(*layout, image_overlay.histogram_mode)) continue;
+ if (READ_INT(*layout, log_window.x)) continue;
+ if (READ_INT(*layout, log_window.y)) continue;
+ if (READ_INT(*layout, log_window.w)) continue;
+ if (READ_INT(*layout, log_window.h)) continue;
+
if (READ_BOOL(*layout, animate)) continue;
log_printf("unknown attribute %s = %s\n", option, value);
if (use_commandline && command_line->startup_full_screen) layout_image_full_screen_start(lw);
if (use_commandline && command_line->startup_in_slideshow) layout_image_slideshow_start(lw);
-
+ if (use_commandline && command_line->log_window_show) log_window_new(lw);
g_free(path);
free_layout_options_content(&lop);
LayoutWindow *lw = data;
layout_exit_fullscreen(lw);
- log_window_new();
+ log_window_new(lw);
}
#include "logwindow.h"
#include "misc.h"
+#include "secure_save.h"
+#include "ui_misc.h"
#include "window.h"
#include <gdk/gdkkeysyms.h>
GdkColor colors[LOG_COUNT];
guint lines;
+ GtkWidget *regexp_box;
+ GtkWidget *bar;
+ GtkWidget *pause;
+ GtkWidget *wrap;
+ GtkWidget *debug_level;
};
typedef struct _LogDef LogDef;
return FALSE;
}
-static LogWindow *log_window_create(void)
+
+static void log_window_pause_cb(GtkWidget *widget, gpointer data)
+{
+ options->log_window.paused = !options->log_window.paused;
+}
+
+static void log_window_line_wrap_cb(GtkWidget *widget, gpointer data)
+{
+ LogWindow *logwin = data;
+
+ options->log_window.line_wrap = !options->log_window.line_wrap;
+
+ if (options->log_window.line_wrap)
+ {
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_WORD);
+ }
+ else
+ {
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_NONE);
+ }
+}
+
+static void log_window_regexp_cb(GtkWidget *text_entry, gpointer data)
+{
+ gchar *new_regexp;
+
+ new_regexp = g_strdup(gtk_entry_get_text(GTK_ENTRY(text_entry)));
+ set_regexp(new_regexp);
+ g_free(new_regexp);
+}
+
+static void log_window_debug_spin_cb(GtkSpinButton *debug_level, gpointer data)
+{
+ set_debug_level(gtk_spin_button_get_value(debug_level));
+}
+
+static LogWindow *log_window_create(LayoutWindow *lw)
{
LogWindow *logwin;
GtkWidget *window;
GtkWidget *text;
GtkTextBuffer *buffer;
GtkTextIter iter;
+ GtkWidget *button;
+ GtkWidget *win_vbox;
+ GtkWidget *textbox;
+ GtkWidget *hbox;
logwin = g_new0(LogWindow, 1);
window = window_new(GTK_WINDOW_TOPLEVEL, "log", NULL, NULL, _("Log"));
- gtk_widget_set_size_request(window, 520, 400);
+ win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE);
+ gtk_container_add(GTK_CONTAINER(window), win_vbox);
+ gtk_widget_show(win_vbox);
+
+ gtk_widget_set_size_request(window, lw->options.log_window.w, lw->options.log_window.h);
+ gtk_window_move(GTK_WINDOW(window), lw->options.log_window.x, lw->options.log_window.y);
+
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
g_signal_connect(G_OBJECT(window), "key_press_event",
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_SHADOW_IN);
- gtk_container_add(GTK_CONTAINER(window), scrolledwin);
+
+ gtk_container_add(GTK_CONTAINER(win_vbox), scrolledwin);
gtk_widget_show(scrolledwin);
+ hbox = pref_box_new(win_vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
+
+ gtk_widget_show(hbox);
+ logwin->debug_level = pref_spin_new_mnemonic(hbox, _("Debug level:"), NULL,
+ 0, 4, 1, 1, get_debug_level(),G_CALLBACK(log_window_debug_spin_cb),
+ logwin->debug_level );
+
+ logwin->pause = pref_button_new(hbox, NULL, "Pause", FALSE,
+ G_CALLBACK(log_window_pause_cb), NULL);
+
+ logwin->wrap = pref_button_new(hbox, NULL, "Line wrap", FALSE,
+ G_CALLBACK(log_window_line_wrap_cb), logwin);
+
+ pref_label_new(hbox, "Filter regexp");
+
+ textbox = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(hbox), textbox);
+ gtk_widget_show(textbox);
+ g_signal_connect(G_OBJECT(textbox), "activate",
+ G_CALLBACK(log_window_regexp_cb), logwin);
+
text = gtk_text_view_new();
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
logwin->scrolledwin = scrolledwin;
logwin->text = text;
logwin->lines = 1;
-
+ logwin->regexp_box = textbox;
+ lw->log_window = logwin->window;
return logwin;
}
GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
GtkTextBuffer *buffer;
GtkTextMark *mark;
+ gchar *regexp;
g_assert(logwin != NULL);
gtk_window_present(GTK_WINDOW(logwin->window));
log_window_append("", LOG_NORMAL); // to flush memorized lines
+
+ regexp = g_strdup(get_regexp());
+ if (regexp != NULL)
+ {
+ gtk_entry_set_text(GTK_ENTRY(logwin->regexp_box), regexp);
+ g_free(regexp);
+ }
}
-void log_window_new(void)
+void log_window_new(LayoutWindow *lw)
{
if (logwindow == NULL)
{
LogWindow *logwin;
- logwin = log_window_create();
+ logwin = log_window_create(lw);
log_window_init(logwin);
logwindow = logwin;
}
log_window_insert_text(buffer, &iter, str, logdefs[type].tag);
- if (gtk_widget_get_visible(GTK_WIDGET(text)))
+ if (!options->log_window.paused)
{
- GtkTextMark *mark;
+ if (gtk_widget_get_visible(GTK_WIDGET(text)))
+ {
+ GtkTextMark *mark;
- mark = gtk_text_buffer_get_mark(buffer, "end");
- gtk_text_view_scroll_mark_onscreen(text, mark);
+ mark = gtk_text_buffer_get_mark(buffer, "end");
+ gtk_text_view_scroll_mark_onscreen(text, mark);
+ }
}
logwindow->lines = gtk_text_buffer_get_line_count(buffer);
LOG_COUNT
} LogType;
-void log_window_new(void);
+void log_window_new(LayoutWindow *lw);
void log_window_append(const gchar *str, LogType type);
command_line->argc = argc;
command_line->argv = argv;
+ command_line->regexp = NULL;
if (argc > 1)
{
remote_list = remote_build_list(remote_list, argc - i, &argv[i], &remote_errors);
}
}
+ else if ((strcmp(cmd_line, "+w") == 0) ||
+ strcmp(cmd_line, "--show-log-window") == 0)
+ {
+ command_line->log_window_show = TRUE;
+ }
+ else if (strncmp(cmd_line, "-o:", 3) == 0)
+ {
+ command_line->log_file = g_strdup(cmd_line + 3);
+ }
+ else if (strncmp(cmd_line, "--log-file:", 11) == 0)
+ {
+ command_line->log_file = g_strdup(cmd_line + 11);
+ }
+ else if (strncmp(cmd_line, "-g:", 3) == 0)
+ {
+ set_regexp(g_strdup(cmd_line+3));
+ }
+ else if (strncmp(cmd_line, "-grep:", 6) == 0)
+ {
+ set_regexp(g_strdup(cmd_line+3));
+ }
else if (strcmp(cmd_line, "-rh") == 0 ||
strcmp(cmd_line, "--remote-help") == 0)
{
print_term(_(" -rh,--remote-help print remote command list\n"));
#ifdef DEBUG
print_term(_(" --debug[=level] turn on debug output\n"));
+ print_term(_(" -g:<regexp>, --grep:<regexp> filter debug output\n"));
#endif
+ print_term(_(" +w, --show-log-window show log window\n"));
+ print_term(_(" -o:<file>, --log-file:<file> save log data to file\n"));
print_term(_(" -v, --version print version info\n"));
print_term(_(" -h, --help show this message\n\n"));
layout_free(lw);
}
+ secure_close(command_line->ssi);
+
gtk_main_quit();
}
}
}
+ if (command_line->log_file)
+ {
+ gchar *pathl;
+ gchar *path = g_strdup(command_line->log_file);
+
+ pathl = path_from_utf8(path);
+ command_line->ssi = secure_open(pathl);
+ }
+
if (command_line->cmd_list ||
(command_line->startup_command_line_collection && command_line->collection_list))
{
options->stereo.fixed_y2 = 1125;
options->log_window_lines = 1000;
+ options->log_window.line_wrap = TRUE;
+ options->log_window.paused = FALSE;
return options;
}
options->image_overlay.state = OSD_SHOW_NOTHING;
options->animate = FALSE;
options->bars_state.hidden = FALSE;
+ options->log_window.w = 520;
+ options->log_window.h = 400;
return options;
}
gint auto_padding;
gint formatted_start;
} cp_mv_rn;
+
+ /* log window */
+ struct {
+ gboolean paused;
+ gboolean line_wrap;
+ } log_window;
};
ConfOptions *options;
utime(ssi->tmp_file_name, &tb);
}
}
- DEBUG_3("rename %s -> %s", ssi->tmp_file_name, ssi->file_name);
if (rename(ssi->tmp_file_name, ssi->file_name) == -1) {
ret = errno;
secsave_errno = SS_ERR_RENAME;
gint histogram_mode;
} image_overlay;
+ struct {
+ gint w;
+ gint h;
+ gint x;
+ gint y;
+ gboolean paused;
+ } log_window;
+
gboolean tools_float;
gboolean tools_hidden;
gboolean toolbar_hidden;
GtkWidget *exif_window;
AnimationData *animation;
+
+ GtkWidget *log_window;
};
struct _ViewDir
gboolean startup_command_line_collection;
gboolean tools_hide;
gboolean tools_show;
+ gboolean log_window_show;
gchar *path;
gchar *file;
GList *cmd_list;
GList *collection_list;
gchar *geometry;
+ gchar *regexp;
+ gchar *log_file;
+ SecureSaveInfo *ssi;
};
#endif
#include "md5-util.h"
#include "filefilter.h"
+#include "secure_save.h"
+
/*
*-----------------------------------------------------------------------------
* generic file information and manipulation routines (public)
text_l = g_locale_from_utf8(text_utf8, -1, NULL, NULL, NULL);
fputs((text_l) ? text_l : text_utf8, stderr);
+ if(command_line && command_line->ssi)
+ secure_fputs(command_line->ssi, (text_l) ? text_l : text_utf8);
g_free(text_l);
}