[ghex/gtk4-port: 77/91] Minor cleanups and start shell of shortcut window.




commit 38621d8dd087edd2a2870e4f32a4556e6139e73c
Author: Logan Rathbone <poprocks gmail com>
Date:   Sat Feb 13 23:24:54 2021 -0500

    Minor cleanups and start shell of shortcut window.
    
    Add help-overlay.ui

 src/ghex-application-window.c  | 32 ++++++++------------------------
 src/ghex-application-window.ui |  6 +++++-
 src/ghex.gresource.xml         |  5 ++++-
 src/gtkhex.c                   |  2 +-
 src/help-overlay.ui            | 30 ++++++++++++++++++++++++++++++
 src/paste-special.c            |  2 +-
 src/preferences.c              | 16 +++-------------
 7 files changed, 52 insertions(+), 41 deletions(-)
---
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index 7491be86..621edcbe 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -587,7 +587,8 @@ copy_special (GtkWidget *widget,
 
        clipboard = gtk_widget_get_clipboard (GTK_WIDGET(self->gh));
 
-       if (! GTK_IS_WIDGET (self->copy_special_dialog)) {
+       if (! GTK_IS_WIDGET (self->copy_special_dialog) ||
+                       ! gtk_widget_get_visible (self->copy_special_dialog)) {
                self->copy_special_dialog = create_copy_special_dialog (self,
                                clipboard);
        }
@@ -607,7 +608,8 @@ paste_special (GtkWidget *widget,
 
        clipboard = gtk_widget_get_clipboard (GTK_WIDGET(self->gh));
 
-       if (! GTK_IS_WIDGET (self->paste_special_dialog)) {
+       if (! GTK_IS_WIDGET (self->paste_special_dialog) ||
+                       gtk_widget_get_visible (self->paste_special_dialog)) {
                self->paste_special_dialog = create_paste_special_dialog (self,
                                clipboard);
        }
@@ -1300,7 +1302,8 @@ open_preferences (GtkWidget *widget,
 
        (void)parameter, (void)action_name;             /* unused */
 
-       if (! GTK_IS_WIDGET (self->prefs_dialog)) {
+       if (! GTK_IS_WIDGET (self->prefs_dialog) ||
+                       ! gtk_widget_get_visible (self->prefs_dialog)) {
                self->prefs_dialog = create_preferences_dialog (GTK_WINDOW(self));
        }
        gtk_widget_show (self->prefs_dialog);
@@ -1309,7 +1312,7 @@ open_preferences (GtkWidget *widget,
 /* --- */
 
 static void
-set_statusbar(GHexApplicationWindow *self, const char *str)
+set_statusbar (GHexApplicationWindow *self, const char *str)
 {
        guint id = 
                gtk_statusbar_get_context_id (GTK_STATUSBAR(self->statusbar),
@@ -1635,25 +1638,6 @@ ghex_application_window_finalize(GObject *gobject)
        G_OBJECT_CLASS(ghex_application_window_parent_class)->finalize(gobject);
 }
 
-#if 0
-static void
-ghex_application_window_startup (GApplication *app)
-{
-       GtkBuilder *builder;
-
-       /* chain up */
-       G_APPLICATION_CLASS(ghex_application_window_parent_class)->startup (app);
-
-       builder = gtk_builder_new_from_resource (builder,
-                       "/org/gnome/ghex/ghex-application-window.ui", NULL);
-
-       gtk_application_set_menubar (GTK_APPLICATION (app),
-                       G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
-
-       g_object_unref (builder);
-}
-#endif
-
 static void
 ghex_application_window_class_init(GHexApplicationWindowClass *klass)
 {
@@ -1837,7 +1821,7 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
        /* WIDGET TEMPLATE .UI */
 
        gtk_widget_class_set_template_from_resource (widget_class,
-                                       "/org/gnome/ghex/ghex-application-window.ui");
+                                       "/org/gnome/GHex/ghex-application-window.ui");
 
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
                        no_doc_label);
diff --git a/src/ghex-application-window.ui b/src/ghex-application-window.ui
index f3142a42..ab4f2d83 100644
--- a/src/ghex-application-window.ui
+++ b/src/ghex-application-window.ui
@@ -117,9 +117,13 @@
 
                <!-- PREFS AND ABOUT -->
                <section>
+                       <item>
+                               <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+                               <attribute name="action">win.show-help-overlay</attribute>
+                       </item>
+
                        <item>
                                <attribute name="label" translatable="yes">_Preferences</attribute>
-                               <attribute name="icon">preferences-other-symbolic</attribute>
                                <attribute name="action">ghex.preferences</attribute>
                        </item>
 
diff --git a/src/ghex.gresource.xml b/src/ghex.gresource.xml
index 9c4d21e5..11c6a522 100644
--- a/src/ghex.gresource.xml
+++ b/src/ghex.gresource.xml
@@ -24,10 +24,13 @@
 -->
 
 <gresources>
-       <gresource prefix="/org/gnome/ghex">
+       <gresource prefix="/org/gnome/GHex">
                <file preprocess="xml-stripblanks" compressed="true">ghex-application-window.ui</file>
                <file preprocess="xml-stripblanks" compressed="true">context-menu.ui</file>
                <file preprocess="xml-stripblanks" compressed="true">preferences.ui</file>
                <file preprocess="xml-stripblanks" compressed="true">paste-special.ui</file>
        </gresource>
+       <gresource prefix="/org/gnome/GHex/gtk">
+               <file preprocess="xml-stripblanks">help-overlay.ui</file>
+       </gresource>
 </gresources>
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 7754841d..44f3f540 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -215,7 +215,7 @@ popup_context_menu(GtkWidget *widget, double x, double y)
        rect.x = x;
        rect.y = y;
 
-       builder = gtk_builder_new_from_resource ("/org/gnome/ghex/context-menu.ui");
+       builder = gtk_builder_new_from_resource ("/org/gnome/GHex/context-menu.ui");
        menu = G_MENU_MODEL(gtk_builder_get_object (builder, "context-menu"));
        popover = gtk_popover_menu_new_from_model (menu);
 
diff --git a/src/help-overlay.ui b/src/help-overlay.ui
new file mode 100644
index 00000000..22988af6
--- /dev/null
+++ b/src/help-overlay.ui
@@ -0,0 +1,30 @@
+<!-- vim: ts=2 sw=2
+-->
+<interface>
+       <object class="GtkShortcutsWindow" id="help_overlay">
+               <child>
+                       <object class="GtkShortcutsSection">
+                               <child>
+                                       <object class="GtkShortcutsGroup">
+                                               <property name="title">General</property>
+
+                                               <child>
+                                                       <object class="GtkShortcutsShortcut">
+                                                               <property name="accelerator">F1</property>
+                                                               <property name="title">Show About 
Dialog</property>
+                                                       </object>
+                                               </child>
+
+                                               <child>
+                                                       <object class="GtkShortcutsShortcut">
+                                                               <property 
name="accelerator">&lt;Control&gt;f</property>
+                                                               <property name="title">Find</property>
+                                                       </object>
+                                               </child>
+
+                                       </object>
+                               </child>
+                       </object>
+               </child>
+       </object>
+</interface>
diff --git a/src/paste-special.c b/src/paste-special.c
index 48da4b69..2c148a39 100644
--- a/src/paste-special.c
+++ b/src/paste-special.c
@@ -27,7 +27,7 @@
 
 /* DEFINES */
 
-#define PASTE_SPECIAL_RESOURCE "/org/gnome/ghex/paste-special.ui"
+#define PASTE_SPECIAL_RESOURCE "/org/gnome/GHex/paste-special.ui"
 
 /* MACROS */
 
diff --git a/src/preferences.c b/src/preferences.c
index 8883a60c..c90b141b 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -44,7 +44,7 @@
 #  define SHADED_BOX_MAX                               1000
 #endif
 
-#define PREFS_RESOURCE "/org/gnome/ghex/preferences.ui"
+#define PREFS_RESOURCE "/org/gnome/GHex/preferences.ui"
 
 /* MACROS */
 
@@ -143,16 +143,6 @@ do_css_stuff(void)
 }
 #undef APPLY_PROVIDER_TO
 
-static void
-close_clicked_cb (GtkButton *button,
-               gpointer user_data)
-{
-       (void)user_data;        /* unused */
-       g_return_if_fail (GTK_IS_WINDOW (prefs_dialog));
-
-       gtk_window_destroy (GTK_WINDOW(prefs_dialog));
-}
-
 static void
 help_clicked_cb (GtkButton *button,
                gpointer user_data)
@@ -409,8 +399,8 @@ setup_signals (void)
 
        /* close and help */
 
-       g_signal_connect (close_button, "clicked",
-                       G_CALLBACK(close_clicked_cb), NULL);
+       g_signal_connect_swapped (close_button, "clicked",
+                       G_CALLBACK(gtk_window_destroy), prefs_dialog);
 
        g_signal_connect (help_button, "clicked",
                        G_CALLBACK(help_clicked_cb), NULL);


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