* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "ui-utildlg.h"
+
+#include <cstdint>
+#include <cstdio>
#include <cstring>
+#include <ctime>
-#include "main.h"
-#include "ui-utildlg.h"
+#include <gdk/gdk.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#include <config.h>
+#include "compat.h"
+#include "debug.h"
#include "filedata.h"
+#include "intl.h"
+#include "main-defines.h"
#include "misc.h"
+#include "options.h"
#include "rcfile.h"
#include "ui-fileops.h"
#include "ui-misc.h"
#include "ui-tabcomp.h"
#include "window.h"
+namespace
+{
+
+constexpr gint max_buffer_size = 16384;
+} // namespace
+
/*
*-----------------------------------------------------------------------------
* generic dialog
gchar *ident_string;
gchar *full_title;
gchar *actual_title;
- gint x, y, h, w;
+ gint x;
+ gint y;
+ gint h;
+ gint w;
gdk_window_get_root_origin(gtk_widget_get_window (gd->dialog), &x, &y);
w = gdk_window_get_width(gtk_widget_get_window (gd->dialog));
gtk_widget_set_can_default(button, TRUE);
g_object_set_data(G_OBJECT(button), "dialog_function", reinterpret_cast<void *>(func_cb));
- gtk_container_add(GTK_CONTAINER(gd->hbox), button);
+ gq_gtk_container_add(GTK_WIDGET(gd->hbox), button);
alternative_order = generic_dialog_get_alternative_button_order(gd->hbox);
void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
{
GtkWidget *vbox;
- gint x, y, w, h;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
GtkWidget *scrolled;
gd->auto_close = auto_close;
gd->data = data;
gd->cancel_cb = cancel_cb;
- gd->dialog = window_new(GTK_WINDOW_TOPLEVEL, role, nullptr, nullptr, title);
+ gd->dialog = window_new(role, nullptr, nullptr, title);
DEBUG_NAME(gd->dialog);
gtk_window_set_type_hint(GTK_WINDOW(gd->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
if (generic_dialog_find_window(title, role, &x, &y, &w, &h))
{
gtk_window_set_default_size(GTK_WINDOW(gd->dialog), w, h);
- gtk_window_move(GTK_WINDOW(gd->dialog), x, y);
+ gq_gtk_window_move(GTK_WINDOW(gd->dialog), x, y);
}
}
gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(scrolled), TRUE);
gtk_scrolled_window_set_propagate_natural_width(GTK_SCROLLED_WINDOW(scrolled), TRUE);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_BUTTON_SPACE);
- gtk_container_add(GTK_CONTAINER(scrolled), vbox);
- gtk_container_add(GTK_CONTAINER(gd->dialog), scrolled);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), vbox);
+ gq_gtk_container_add(GTK_WIDGET(gd->dialog), scrolled);
gtk_widget_show(scrolled);
gtk_widget_show(vbox);
{
auto appimage_data = static_cast<AppImageData *>(data);
- if (appimage_data->window && gtk_window_get_opacity(GTK_WINDOW(appimage_data->window)) != 0)
+ if (appimage_data->window && gtk_widget_get_opacity(appimage_data->window) != 0)
{
g_source_remove(appimage_data->id);
}
if (appimage_data->window)
{
- g_object_unref(appimage_data->window);
+ gq_gtk_widget_destroy(appimage_data->window);
}
g_thread_pool_free(appimage_data->thread_pool, TRUE, TRUE);
{
auto appimage_data = static_cast<AppImageData *>(data);
- gtk_window_set_opacity(GTK_WINDOW(appimage_data->window), (gtk_window_get_opacity(GTK_WINDOW(appimage_data->window)) - 0.02));
+ gtk_widget_set_opacity(appimage_data->window, (gtk_widget_get_opacity(appimage_data->window) - 0.02));
- if (gtk_window_get_opacity(GTK_WINDOW(appimage_data->window)) == 0)
+ if (gtk_widget_get_opacity(appimage_data->window) == 0)
{
g_idle_add(appimage_notification_close_cb, data);
appimage_data->window = GTK_WIDGET(gtk_builder_get_object(builder, "appimage_notification"));
- gtk_window_move(GTK_WINDOW(appimage_data->window), (gdk_screen_width() * 0.8), (gdk_screen_height() / 20));
+ GdkRectangle workarea;
+ gdk_monitor_get_workarea(gdk_display_get_primary_monitor(gdk_display_get_default()),
+ &workarea);
+ gq_gtk_window_move(GTK_WINDOW(appimage_data->window), workarea.width * 0.8, workarea.height / 20);
g_signal_connect(appimage_data->window, "focus-in-event", G_CALLBACK(user_close_cb), appimage_data);
appimage_data->id = g_timeout_add(100, appimage_notification_fade_cb, appimage_data);
void appimage_notification_func(gpointer data, gpointer)
{
+ FILE *pipe;
+ GNetworkMonitor *net_mon;
+ GSocketConnectable *geeqie_github;
auto appimage_data = static_cast<AppImageData *>(data);
+ char buffer[max_buffer_size];
+ char result[max_buffer_size];
gboolean internet_available = FALSE;
+ gchar **github_split;
gchar **version_split;
- GFile *file_github;
- GFileInfo *file_info;
- GNetworkMonitor *net_mon;
- GSocketConnectable *geeqie_github;
+ gchar *start_date;
struct tm current_version_date;
- int64_t file_github_date;
- unsigned int year, month, day;
+ struct tm github_version_date;
+ unsigned int day;
+ unsigned int month;
+ unsigned int year;
/* If this is a release version, do not check for updates */
if (g_strrstr(VERSION, "git"))
/* VERSION looks like: 2.0.1+git20220116-c791cbee */
version_split = g_strsplit_set(VERSION, "+-", -1);
- file_github = g_file_new_for_uri("https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie-latest-x86_64.AppImage");
- file_info = g_file_query_info(file_github, "time::modified", G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
-
- file_github_date = g_file_info_get_attribute_uint64(file_info, "time::modified");
-
sscanf(version_split[1] + 3, "%4u%2u%2u", &year, &month, &day);
current_version_date.tm_year = year - 1900;
current_version_date.tm_mon = month - 1;
current_version_date.tm_sec = 0;
current_version_date.tm_isdst = 0;
- if (file_github_date > mktime(¤t_version_date))
+ pipe = popen("curl --max-time 2 --silent https://api.github.com/repos/BestImageViewer/geeqie/releases/tags/continuous", "r");
+
+ if (pipe == nullptr)
{
- show_notification_message(appimage_data);
+ log_printf("Failed to get date from GitHub");
+ }
+ else
+ {
+ while (fgets(buffer, max_buffer_size, pipe) != nullptr)
+ {
+ strcat(result, buffer);
+ }
+ pclose(pipe);
+
+ /* GitHub date looks like: "published_at": "2024-04-17T08:50:08Z" */
+ start_date = g_strstr_len(result, -1, "published");
+ start_date[26] = '\0';
+
+ github_split = g_strsplit_set(start_date, "\"-", -1);
+
+ sscanf(github_split[2], "%4u", &year);
+ sscanf(github_split[3], "%2u", &month);
+ sscanf(github_split[4], "%2u", &day);
+
+ github_version_date.tm_year = year - 1900;
+ github_version_date.tm_mon = month - 1;
+ github_version_date.tm_mday = day;
+ github_version_date.tm_hour = 0;
+ github_version_date.tm_min = 0;
+ github_version_date.tm_sec = 0;
+ github_version_date.tm_isdst = 0;
+
+ if (mktime(&github_version_date) > mktime(¤t_version_date))
+ {
+ show_notification_message(appimage_data);
+ }
+
+ g_strfreev(github_split);
}
-
- g_object_unref(file_github);
- g_object_unref(file_info);
g_strfreev(version_split);
}
}
{
auto fdlg = static_cast<FileDialog *>(data);
g_free(fdlg->dest_path);
- fdlg->dest_path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
+ fdlg->dest_path = remove_trailing_slash(gq_gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
}
static void file_dialog_entry_enter_cb(const gchar *, gpointer data)
gtk_widget_grab_focus(fdlg->entry);
if (fdlg->dest_path)
{
- gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path);
+ gq_gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path);
gtk_editable_set_position(GTK_EDITABLE(fdlg->entry), strlen(fdlg->dest_path));
}