GTK4: gtk_window_new()
authorColin Clark <colin.clark@cclark.uk>
Mon, 25 Sep 2023 15:41:17 +0000 (16:41 +0100)
committerColin Clark <colin.clark@cclark.uk>
Mon, 25 Sep 2023 15:41:17 +0000 (16:41 +0100)
GTK4 migration

gtk_window_new() no longer takes a parameter

16 files changed:
src/advanced-exif.cc
src/bar.cc
src/collect.cc
src/desktop-file.cc
src/dupe.cc
src/fullscreen.cc
src/img-view.cc
src/layout.cc
src/logwindow.cc
src/pan-view/pan-view.cc
src/preferences.cc
src/search.cc
src/ui-help.cc
src/ui-utildlg.cc
src/window.cc
src/window.h

index 6bf0df9..584f957 100644 (file)
@@ -431,7 +431,7 @@ GtkWidget *advanced_exif_new(LayoutWindow *lw)
 
        ew = g_new0(ExifWin, 1);
 
-       ew->window = window_new(GTK_WINDOW_TOPLEVEL, "view", nullptr, nullptr, _("Metadata"));
+       ew->window = window_new("view", nullptr, nullptr, _("Metadata"));
        DEBUG_NAME(ew->window);
 
        geometry.min_width = 900;
index 97e3d48..2dba35d 100644 (file)
@@ -279,6 +279,11 @@ static void height_spin_key_press_cb(GtkEventControllerKey *, gint keyval, guint
                }
 }
 
+static void expander_height_cb(GtkWindow *widget, GdkEvent *, gpointer)
+{
+       gq_gtk_widget_destroy(GTK_WIDGET(widget));
+}
+
 static void bar_expander_height_cb(GtkWidget *, gpointer data)
 {
        auto expander = static_cast<GtkWidget *>(data);
@@ -301,11 +306,17 @@ static void bar_expander_height_cb(GtkWidget *, gpointer data)
        list = gtk_container_get_children(GTK_CONTAINER(expander));
        data_box = static_cast<GtkWidget *>(list->data);
 
-       window = gtk_window_new(GTK_WINDOW_POPUP);
+#ifdef HAVE_GTK4
+       window = gtk_window_new();
+#else
+       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#endif
 
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+       gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
        gq_gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
        gtk_window_set_default_size(GTK_WINDOW(window), 50, 30); //** @FIXME set these values in a more sensible way */
+       g_signal_connect(window, "key-press-event", G_CALLBACK(expander_height_cb), nullptr);
 
        gtk_window_move(GTK_WINDOW(window), x, y);
        gtk_widget_show(window);
index f42e546..544a6aa 100644 (file)
@@ -1330,7 +1330,7 @@ CollectWindow *collection_window_new(const gchar *path)
 
        cw->cd = collection_new(path);
 
-       cw->window = window_new(GTK_WINDOW_TOPLEVEL, "collection", PIXBUF_INLINE_ICON_BOOK, nullptr, nullptr);
+       cw->window = window_new("collection", PIXBUF_INLINE_ICON_BOOK, nullptr, nullptr);
        DEBUG_NAME(cw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
index 3c0ffb3..710ea2a 100644 (file)
@@ -182,7 +182,7 @@ static void editor_window_new(const gchar *src_path, const gchar *desktop_name)
        ew = g_new0(EditorWindow, 1);
 
 
-       ew->window = window_new(GTK_WINDOW_TOPLEVEL, "Desktop", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Desktop file"));
+       ew->window = window_new("Desktop", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Desktop file"));
        DEBUG_NAME(ew->window);
        gtk_window_set_type_hint(GTK_WINDOW(ew->window), GDK_WINDOW_TYPE_HINT_DIALOG);
 
@@ -540,7 +540,7 @@ static void editor_list_window_create()
 
        editor_list_window = ewl = g_new0(EditorListWindow, 1);
 
-       ewl->window = window_new(GTK_WINDOW_TOPLEVEL, "editors", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Plugins"));
+       ewl->window = window_new("editors", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Plugins"));
        DEBUG_NAME(ewl->window);
        gtk_window_set_type_hint(GTK_WINDOW(ewl->window), GDK_WINDOW_TYPE_HINT_DIALOG);
        g_signal_connect(G_OBJECT(ewl->window), "delete_event",
index f9d61e6..0b75eda 100644 (file)
@@ -4600,7 +4600,7 @@ DupeWindow *dupe_window_new()
        if (options->duplicates_match == DUPE_MATCH_NAME_CI_CONTENT) dw->match_mask = DUPE_MATCH_NAME_CI_CONTENT;
        if (options->duplicates_match == DUPE_MATCH_ALL) dw->match_mask = DUPE_MATCH_ALL;
 
-       dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", nullptr, nullptr, _("Find duplicates"));
+       dw->window = window_new("dupe", nullptr, nullptr, _("Find duplicates"));
        DEBUG_NAME(dw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
index 0df230a..c3d1958 100644 (file)
@@ -242,7 +242,7 @@ FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd,
        fullscreen_prefs_get_geometry(options->fullscreen.screen, window, &x, &y, &w, &h,
                                      &screen, &fs->same_region);
 
-       fs->window = window_new(GTK_WINDOW_TOPLEVEL, "fullscreen", nullptr, nullptr, _("Full screen"));
+       fs->window = window_new("fullscreen", nullptr, nullptr, _("Full screen"));
        DEBUG_NAME(fs->window);
 
        g_signal_connect(G_OBJECT(fs->window), "delete_event",
index cd529dc..3e1884b 100644 (file)
@@ -908,7 +908,7 @@ static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionDat
 
        vw = g_new0(ViewWindow, 1);
 
-       vw->window = window_new(GTK_WINDOW_TOPLEVEL, "view", PIXBUF_INLINE_ICON_VIEW, nullptr, nullptr);
+       vw->window = window_new("view", PIXBUF_INLINE_ICON_VIEW, nullptr, nullptr);
        DEBUG_NAME(vw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
index 0053ace..0065de5 100644 (file)
@@ -1609,7 +1609,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
                GdkGeometry geometry;
                GdkWindowHints hints;
 
-               lw->tools = window_new(GTK_WINDOW_TOPLEVEL, "tools", PIXBUF_INLINE_ICON_TOOLS, nullptr, _("Tools"));
+               lw->tools = window_new("tools", PIXBUF_INLINE_ICON_TOOLS, nullptr, _("Tools"));
                DEBUG_NAME(lw->tools);
                g_signal_connect(G_OBJECT(lw->tools), "delete_event",
                                 G_CALLBACK(layout_tools_delete_cb), lw);
@@ -2318,7 +2318,7 @@ void layout_show_config_window(LayoutWindow *lw)
        layout_sync_options_with_current_state(lw);
        copy_layout_options(&lc->options, &lw->options);
 
-       lc->configwindow = window_new(GTK_WINDOW_TOPLEVEL, "Layout", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Window options and layout"));
+       lc->configwindow = window_new("Layout", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Window options and layout"));
        DEBUG_NAME(lc->configwindow);
        gtk_window_set_type_hint(GTK_WINDOW(lc->configwindow), GDK_WINDOW_TYPE_HINT_DIALOG);
 
@@ -2641,7 +2641,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
 
        /* window */
 
-       lw->window = window_new(GTK_WINDOW_TOPLEVEL, GQ_APPNAME_LC, nullptr, nullptr, nullptr);
+       lw->window = window_new(GQ_APPNAME_LC, nullptr, nullptr, nullptr);
        DEBUG_NAME(lw->window);
        gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE);
        gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0);
index bd72919..502fb07 100644 (file)
@@ -402,7 +402,7 @@ static LogWindow *log_window_create(LayoutWindow *lw)
 
        logwin = g_new0(LogWindow, 1);
 
-       window = window_new(GTK_WINDOW_TOPLEVEL, "log", nullptr, nullptr, _("Log"));
+       window = window_new("log", nullptr, nullptr, _("Log"));
        DEBUG_NAME(window);
        win_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
        gq_gtk_container_add(GTK_WIDGET(window), win_vbox);
index 93d7627..1f44a1f 100644 (file)
@@ -1830,7 +1830,7 @@ static void pan_window_new_real(FileData *dir_fd)
 
        pw->idle_id = 0;
 
-       pw->window = window_new(GTK_WINDOW_TOPLEVEL, "panview", nullptr, nullptr, _("Pan View"));
+       pw->window = window_new("panview", nullptr, nullptr, _("Pan View"));
        DEBUG_NAME(pw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
index 96930a8..956b083 100644 (file)
@@ -4023,7 +4023,7 @@ static void config_window_create(LayoutWindow *lw)
 
        if (!c_options) c_options = init_options(nullptr);
 
-       configwindow = window_new(GTK_WINDOW_TOPLEVEL, "preferences", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Preferences"));
+       configwindow = window_new("preferences", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Preferences"));
        DEBUG_NAME(configwindow);
        gtk_window_set_type_hint(GTK_WINDOW(configwindow), GDK_WINDOW_TYPE_HINT_DIALOG);
        g_signal_connect(G_OBJECT(configwindow), "delete_event",
index 7fc3da9..5c55b9d 100644 (file)
@@ -3336,7 +3336,7 @@ void search_new(FileData *dir_fd, FileData *example_file)
                sd->search_similarity_path = g_strdup(example_file->path);
                }
 
-       sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", nullptr, nullptr, _("Image search"));
+       sd->window = window_new("search", nullptr, nullptr, _("Image search"));
        DEBUG_NAME(sd->window);
 
        gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);
index 2608bbe..3e9832a 100644 (file)
@@ -201,7 +201,7 @@ GtkWidget *help_window_new(const gchar *title,
 
        /* window */
 
-       window = window_new(GTK_WINDOW_TOPLEVEL, subclass, nullptr, nullptr, title);
+       window = window_new(subclass, nullptr, nullptr, title);
        DEBUG_NAME(window);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
        gtk_window_set_default_size(GTK_WINDOW(window), HELP_WINDOW_WIDTH, HELP_WINDOW_HEIGHT);
index ab2905e..91c98d6 100644 (file)
@@ -391,7 +391,7 @@ static void generic_dialog_setup(GenericDialog *gd,
        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);
 
index 81c9733..fc5a654 100644 (file)
 #include "ui-misc.h"
 #include "ui-utildlg.h"
 
-GtkWidget *window_new(GtkWindowType type, const gchar *role, const gchar *icon,
-                     const gchar *icon_file, const gchar *subtitle)
+GtkWidget *window_new(const gchar *role, const gchar *icon, const gchar *icon_file, const gchar *subtitle)
 {
        gchar *title;
        GtkWidget *window;
 
-       window = gtk_window_new(type);
+#ifdef HAVE_GTK4
+       window = gtk_window_new();
+#else
+       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#endif
        if (!window) return nullptr;
 
        if (subtitle)
index c1c4921..71ee4b6 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef WINDOW_H
 #define WINDOW_H
 
-GtkWidget *window_new(GtkWindowType type, const gchar *role, const gchar *icon,
+GtkWidget *window_new(const gchar *role, const gchar *icon,
                      const gchar *icon_file, const gchar *subtitle);
 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file);
 gboolean window_maximized(GtkWidget *window);