[gedit/wip/open-recent-menu] Window: finer control of the open recent menu




commit b969635a218f4946b6c85851a05578847f086dd5
Author: Sébastien Wilmet <swilmet informatique-libre be>
Date:   Thu Jul 21 17:04:56 2022 +0200

    Window: finer control of the open recent menu
    
    Amtk 5.5.2 is needed for
    amtk_application_window_create_open_recent_menu_base().
    
    When using amtk_application_window_create_open_recent_menu() (so the
    more complete one), it calls g_application_open() which is not suitable
    in gedit, because it calls _gedit_cmd_load_files_from_prompt(). From
    prompt, if the file doesn't exist, it sets the 'create' param to TRUE,
    which creates the file, so it doesn't show a warning infobar if the file
    doesn't exist.
    
    When opening a file from the recent menu, we *want* a warning infobar if
    the file doesn't exist instead of showing an empty document. (if it
    shows an empty document, we may think that the file *exists* and is
    empty).

 gedit/gedit-window.c | 10 +++++++---
 meson.build          |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 2f9a2076f..889b5541c 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2626,7 +2626,7 @@ create_open_buttons (GeditWindow    *window,
        GtkWidget *open_dialog_button;
        GtkWidget *my_open_recent_button;
        AmtkApplicationWindow *amtk_window;
-       GtkWidget *recent_menu;
+       GtkRecentChooserMenu *recent_menu;
 
        /* It currently needs to be a GtkBox, not a GtkGrid, because GtkGrid and
         * GTK_STYLE_CLASS_LINKED doesn't work as expected in a RTL locale.
@@ -2643,9 +2643,13 @@ create_open_buttons (GeditWindow    *window,
        my_open_recent_button = gtk_menu_button_new ();
        gtk_widget_set_tooltip_text (my_open_recent_button, _("Open a recently used file"));
 
+       recent_menu = amtk_application_window_create_open_recent_menu_base ();
+
        amtk_window = amtk_application_window_get_from_gtk_application_window (GTK_APPLICATION_WINDOW 
(window));
-       recent_menu = amtk_application_window_create_open_recent_menu (amtk_window);
-       gtk_menu_button_set_popup (GTK_MENU_BUTTON (my_open_recent_button), recent_menu);
+       amtk_application_window_connect_recent_chooser_menu_to_statusbar (amtk_window, recent_menu);
+
+       gtk_menu_button_set_popup (GTK_MENU_BUTTON (my_open_recent_button),
+                                  GTK_WIDGET (recent_menu));
 
        gtk_container_add (GTK_CONTAINER (hbox), open_dialog_button);
        gtk_container_add (GTK_CONTAINER (hbox), my_open_recent_button);
diff --git a/meson.build b/meson.build
index a9ce7d0da..fca16772d 100644
--- a/meson.build
+++ b/meson.build
@@ -45,6 +45,7 @@ gio_dep = dependency('gio-2.0', version: '>= 2.70')
 libgedit_public_deps = [
   gio_dep,
   dependency('gtk+-3.0', version: '>= 3.22'),
+  dependency('amtk-5', version: '>= 5.5.2'),
   dependency('tepl-6', version: '>= 6.1.2'),
   dependency('libpeas-gtk-1.0'),
 ]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]