* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "main.h"
+
+#include <unistd.h>
+
+#include <clocale>
#include <csignal>
-#include <sys/mman.h>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
-#ifdef G_OS_UNIX
-#include <pwd.h>
+#include <config.h>
+
+#if HAVE_CLUTTER
+# include <clutter-gtk/clutter-gtk.h>
+# include <clutter/clutter.h>
#endif
-#include <clocale>
-#include "main.h"
+#if HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+#endif
+
+#if HAVE_DEVELOPER
+#include "third-party/backward.h"
+#endif
+#include "cache-maint.h"
#include "cache.h"
-#include "collect.h"
#include "collect-io.h"
+#include "collect.h"
+#include "compat.h"
+#include "debug.h"
+#include "exif.h"
#include "filedata.h"
#include "filefilter.h"
+#include "glua.h"
+#include "histogram.h"
#include "history-list.h"
#include "image.h"
#include "img-view.h"
+#include "intl.h"
#include "layout-image.h"
#include "layout-util.h"
+#include "layout.h"
+#include "main-defines.h"
+#include "metadata.h"
#include "misc.h"
+#include "options.h"
+#include "pixbuf-util.h"
#include "rcfile.h"
#include "remote.h"
#include "secure-save.h"
+#include "third-party/whereami.h"
+#include "thumb.h"
#include "ui-fileops.h"
#include "ui-utildlg.h"
-#include "cache-maint.h"
-#include "thumb.h"
-#include "metadata.h"
-#include "exif.h"
-#include "histogram.h"
-#include "pixbuf-util.h"
-#include "glua.h"
-#include "whereami.h"
-
-#ifdef HAVE_CLUTTER
-#include <clutter-gtk/clutter-gtk.h>
-#endif
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
gboolean thumb_format_changed = FALSE;
static RemoteConnection *remote_connection = nullptr;
guint64 addr;
guint64 char_index;
ssize_t len;
-#ifdef HAVE_EXECINFO_H
+#if HAVE_EXECINFO_H
gint bt_size;
void *bt[1024];
#endif
len = write(STDERR_FILENO, "\n", 1);
}
-#ifdef HAVE_EXECINFO_H
+#if HAVE_EXECINFO_H
bt_size = backtrace(bt, 1024);
backtrace_symbols_fd(bt, bt_size, STDERR_FILENO);
#endif
#else /* defined(SA_SIGINFO) */
void sig_handler_cb(int)
{
-#ifdef HAVE_EXECINFO_H
+#if HAVE_EXECINFO_H
gint bt_size;
void *bt[1024];
#endif
write(STDERR_FILENO, "Geeqie fatal error\n", 19);
write(STDERR_FILENO, "Signal: Segmentation fault\n", 27);
-#ifdef HAVE_EXECINFO_H
+#if HAVE_EXECINFO_H
bt_size = backtrace(bt, 1024);
backtrace_symbols_fd(bt, bt_size, STDERR_FILENO);
#endif
printf_term(FALSE, "%s %s GTK%d\n", GQ_APPNAME, VERSION, gtk_major_version);
exit(0);
}
- else if (strcmp(cmd_line, "--alternate") == 0)
- {
- /* enable faster experimental algorithm */
- log_printf("Alternate similarity algorithm enabled\n");
- image_sim_alternate_set(TRUE);
- }
else if (strcmp(cmd_line, "-h") == 0 ||
strcmp(cmd_line, "--help") == 0)
{
print_term(FALSE, _(" --geometry=WxH+XOFF+YOFF set main window location\n"));
print_term(FALSE, _(" -h, --help show this message\n"));
print_term(FALSE, _(" -l, --list [files] [collections] open collection window for command line\n"));
- print_term(FALSE, _(" -n, --new-instance open a new instance of Geeqie\n"));
- print_term(FALSE, _(" -o:, --log-file:<file> save log data to file\n"));
+ print_term(FALSE, _(" -n, --new-instance open a new instance of Geeqie *\n"));
+ print_term(FALSE, _(" -o:, --log-file:<file> save log data to file\n"));
print_term(FALSE, _(" -r, --remote send following commands to open window\n"));
print_term(FALSE, _(" -rh, --remote-help print remote command list\n"));
print_term(FALSE, _(" -s, --slideshow start in slideshow mode\n"));
print_term(FALSE, _(" +w, --show-log-window show log window\n"));
#ifdef DEBUG
print_term(FALSE, _(" --debug[=level] turn on debug output\n"));
- print_term(FALSE, _(" -g:, --grep:<regexp> filter debug output\n"));
+ print_term(FALSE, _(" -g:, --grep:<regexp> filter debug output\n"));
#endif
-#if 0
- /* these options are not officially supported!
- * only for testing new features, no need to translate them */
- print_term(FALSE, " --alternate use alternate similarity algorithm\n");
-#endif
print_term(FALSE, "\n");
+ print_term(FALSE, "* Normally a single set of configuration files is used for all instances.\nHowever, the environment variables XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME\ncan be used to modify this behavior on an individual basis e.g.\n\nXDG_CONFIG_HOME=/tmp/a XDG_CACHE_HOME=/tmp/b geeqie\n\n");
remote_help();
dialog_warning = gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", "Invalid parameter(s):");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog_warning), "%s", command_line_errors->str);
gtk_window_set_title(GTK_WINDOW(dialog_warning), GQ_APPNAME);
- gtk_window_set_keep_above(GTK_WINDOW(dialog_warning), TRUE);
+ gq_gtk_window_set_keep_above(GTK_WINDOW(dialog_warning), TRUE);
gtk_dialog_run(GTK_DIALOG(dialog_warning));
- gtk_widget_destroy(dialog_warning);
+ g_object_unref(dialog_warning);
g_string_free(command_line_errors, TRUE);
exit(EXIT_FAILURE);
dialog_warning = gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", "Invalid parameter(s):");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog_warning), "%s", command_line_errors->str);
gtk_window_set_title(GTK_WINDOW(dialog_warning), GQ_APPNAME);
- gtk_window_set_keep_above(GTK_WINDOW(dialog_warning), TRUE);
+ gq_gtk_window_set_keep_above(GTK_WINDOW(dialog_warning), TRUE);
gtk_dialog_run(GTK_DIALOG(dialog_warning));
- gtk_widget_destroy(dialog_warning);
+ g_object_unref(dialog_warning);
g_string_free(command_line_errors, TRUE);
exit(EXIT_FAILURE);
#endif
}
-#ifdef HAVE_CLUTTER
+#if HAVE_CLUTTER
static gboolean parse_command_line_for_clutter_option(gint argc, gchar *argv[])
{
const gchar *clutter_option = "--disable-clutter";
{
GString *gstring = g_string_new(changed ? nullptr : "; ");
auto ssi = static_cast<SecureSaveInfo *>(data);
- gchar *tmp, *name;
+ gchar *tmp;
+ gchar *name;
g_string_append(gstring, "(gtk_accel_path \"");
GtkWidget *parent;
LayoutWindow *lw;
gchar *msg;
+ GString *message;
if (exit_dialog)
{
return TRUE;
}
- if (!collection_window_modified_exists()) return FALSE;
+ if (!collection_window_modified_exists() && (layout_window_count() == 1)) return FALSE;
parent = nullptr;
lw = nullptr;
exit_confirm_cancel_cb, nullptr);
g_free(msg);
msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME);
- generic_dialog_add_message(exit_dialog, GTK_STOCK_DIALOG_QUESTION,
- msg, _("Collections have been modified. Quit anyway?"), TRUE);
+
+ message = g_string_new(nullptr);
+
+ if (collection_window_modified_exists())
+ {
+ message = g_string_append(message, _("Collections have been modified.\n"));
+ }
+
+ if (layout_window_count() > 1)
+ {
+ g_string_append_printf(message, _("%d windows are open.\n\n"), layout_window_count());
+ }
+
+ message = g_string_append(message, _("Quit anyway?"));
+
+ generic_dialog_add_message(exit_dialog, GQ_ICON_DIALOG_QUESTION, msg, message->str, TRUE);
g_free(msg);
generic_dialog_add_button(exit_dialog, GQ_ICON_QUIT, _("Quit"), exit_confirm_exit_cb, TRUE);
gtk_widget_show(exit_dialog->dialog);
+ g_string_free(message, TRUE);
+
return TRUE;
}
}
#endif
-static void setup_sigbus_handler_unused(void)
+static void setup_sigbus_handler_unused()
{
#if defined(SIGBUS) && defined(SA_SIGINFO)
struct sigaction sigbus_action;
sigbus_action.sa_sigaction = sigbus_handler_cb_unused;
sigbus_action.sa_flags = SA_SIGINFO;
- sigaction(SIGBUS, &sigbus_action, NULL);
+ sigaction(SIGBUS, &sigbus_action, nullptr);
#endif
}
#pragma GCC diagnostic pop
-#ifndef HAVE_DEVELOPER
+#if !HAVE_DEVELOPER
static void setup_sig_handler()
{
struct sigaction sigsegv_action;
static void set_theme_bg_color()
{
GdkRGBA bg_color;
- GdkColor theme_color;
+ GdkRGBA theme_color;
GtkStyleContext *style_context;
GList *work;
LayoutWindow *lw;
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;
+ theme_color.red = bg_color.red ;
+ theme_color.green = bg_color.green ;
+ theme_color.blue = bg_color.blue ;
while (work)
{
gq_htmldir = g_build_filename(gq_prefix, GQ_HTMLDIR, NULL);
gq_appdir = g_build_filename(gq_prefix, GQ_APPDIR, NULL);
gq_bindir = g_build_filename(gq_prefix, GQ_BINDIR, NULL);
- desktop_file_template = g_build_filename(gq_appdir, "template.desktop", NULL);
+ desktop_file_template = g_build_filename(gq_appdir, "org.geeqie.template.desktop", NULL);
g_free(dirname);
g_free(path);
gint main(gint argc, gchar *argv[])
{
- CollectionData *first_collection = nullptr;
- gchar *buf;
CollectionData *cd = nullptr;
+ CollectionData *first_collection = nullptr;
gboolean disable_clutter = FALSE;
gboolean single_dir = TRUE;
- LayoutWindow *lw;
+ gchar *buf;
+ GdkScreen *screen;
+ GtkCssProvider *provider;
GtkSettings *default_settings;
+ LayoutWindow *lw;
gdk_set_allowed_backends("x11,*");
gdk_threads_enter();
/* seg. fault handler */
-#ifdef HAVE_DEVELOPER
+#if HAVE_DEVELOPER
backward::SignalHandling sh{};
#else
setup_sig_handler();
exif_init();
-#ifdef HAVE_LUA
+#if HAVE_LUA
lua_init();
#endif
parse_command_line_for_debug_option(argc, argv);
DEBUG_1("%s main: gtk_init", get_exec_time());
-#ifdef HAVE_CLUTTER
+#if HAVE_CLUTTER
if (parse_command_line_for_clutter_option(argc, argv))
{
disable_clutter = TRUE;
setup_env_path();
+ screen = gdk_screen_get_default();
+ provider = gtk_css_provider_new();
+ gtk_css_provider_load_from_resource(provider, GQ_RESOURCE_PATH_UI "/custom.css");
+ gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
if (parse_command_line_for_cache_maintenance_option(argc, argv))
{
process_command_line_for_cache_maintenance_option(argc, argv);
filter_rebuild();
}
- #ifdef HAVE_CLUTTER
+ #if HAVE_CLUTTER
/** @FIXME For the background of this see:
* https://github.com/BestImageViewer/geeqie/issues/397
* The feature CLUTTER_FEATURE_SWAP_EVENTS indictates if the
}
/* Show a fade-out notification window if the server has a newer AppImage version */
- if (options->appimage_notifications && g_getenv("APPDIR") && strstr(g_getenv("APPDIR"), "/tmp/.mount_Geeqie"))
+ if (options->appimage_notifications)
{
- appimage_notification();
+ if (g_getenv("APPDIR") && strstr(g_getenv("APPDIR"), "/tmp/.mount_Geeqie"))
+ {
+ appimage_notification();
+ }
+ else if (g_strstr_len(gq_executable_path, -1, "AppRun"))
+ {
+ /* Probably running an extracted AppImage */
+ appimage_notification();
+ }
}
DEBUG_1("%s main: gtk_main", get_exec_time());