#include "filedata.h"
#include "filefilter.h"
#include "history_list.h"
+#include "image.h"
#include "image-overlay.h"
+#include "img-view.h"
#include "layout.h"
#include "layout_image.h"
#include "layout_util.h"
#include "histogram.h"
#include "pixbuf_util.h"
#include "glua.h"
+#include "whereami.h"
#ifdef HAVE_CLUTTER
#include <clutter-gtk/clutter-gtk.h>
#endif
}
+static void set_theme_bg_color()
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA bg_color;
+ GdkColor theme_color;
+ GtkStyleContext *style_context;
+ GList *work;
+ LayoutWindow *lw;
+
+ if (!options->image.use_custom_border_color)
+ {
+ work = layout_window_list;
+ lw = work->data;
+
+ style_context = gtk_widget_get_style_context(lw->window);
+ gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);
+
+ theme_color.red = bg_color.red * 65535;
+ theme_color.green = bg_color.green * 65535;
+ theme_color.blue = bg_color.blue * 65535;
+
+ while (work)
+ {
+ lw = work->data;
+ image_background_set_color(lw->image, &theme_color);
+ work = work->next;
+ }
+ }
+
+ view_window_colors_update();
+#endif
+}
+
+static gboolean theme_change_cb(GObject *gobject, GParamSpec *pspec, gpointer data)
+{
+ set_theme_bg_color();
+
+ return FALSE;
+}
+
/**
* @brief Set up the application paths
*
{
gchar *dirname;
gchar *tmp;
- gchar **env;
-
- env = g_get_environ();
+ gint length;
+ gchar *path;
- if (argv[0][0] == G_DIR_SEPARATOR)
- {
- gq_executable_path = g_strdup(argv[0]);
- }
- else
- {
- gq_executable_path = g_build_filename(g_environ_getenv(env, "PWD"), argv[0], NULL);
- }
+ length = wai_getExecutablePath(NULL, 0, NULL);
+ path = (gchar *)malloc(length + 1);
+ wai_getExecutablePath(path, length, NULL);
+ path[length] = '\0';
+ gq_executable_path = g_strdup(path);
dirname = g_path_get_dirname(gq_executable_path); // default is /usr/bin/
gq_prefix = g_path_get_dirname(dirname);
g_free(tmp);
g_free(dirname);
- g_strfreev(env);
+ g_free(path);
+}
+
+gboolean stderr_channel_cb(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ static GString *message_str = NULL;
+ gchar buf[10] = {0};
+ gsize count;
+
+ if (!message_str)
+ {
+ message_str = g_string_new(NULL);
+ }
+
+ g_io_channel_read_chars(source, buf, 1, &count, NULL);
+
+ if (count > 0)
+ {
+ if (buf[0] == '\n')
+ {
+ log_printf("%s", message_str->str);
+ g_string_free(message_str, TRUE);
+ message_str = NULL;
+ }
+ else
+ {
+ message_str = g_string_append_c(message_str, buf[0]);
+ }
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
gint main(gint argc, gchar *argv[])
gboolean disable_clutter = FALSE;
gboolean single_dir = TRUE;
LayoutWindow *lw;
+ GtkSettings *default_settings;
+ gint fd_stderr[2];
+ GIOChannel *stderr_channel;
#ifdef HAVE_GTHREAD
#if !GLIB_CHECK_VERSION(2,32,0)
textdomain(PACKAGE);
#endif
+ /* Tee stderr to log window */
+ if (pipe(fd_stderr) == 0)
+ {
+ if (dup2(fd_stderr[1], fileno(stderr)) != -1)
+ {
+ close(fd_stderr[1]);
+ stderr_channel = g_io_channel_unix_new(fd_stderr[0]);
+ g_io_add_watch(stderr_channel, G_IO_IN, (GIOFunc)stderr_channel_cb, NULL);
+ }
+ }
+
exif_init();
#ifdef HAVE_LUA
g_free(buf);
marks_load();
- }
+
+ default_settings = gtk_settings_get_default();
+ g_signal_connect(default_settings, "notify::gtk-theme-name", G_CALLBACK(theme_change_cb), NULL);
+ set_theme_bg_color();
+ }
DEBUG_1("%s main: gtk_main", get_exec_time());
gtk_main();