[ghex/custom-statusbar] Initial commit: custom statusbar with monospace support
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex/custom-statusbar] Initial commit: custom statusbar with monospace support
- Date: Wed, 20 Apr 2022 17:59:22 +0000 (UTC)
commit 5f5a85cbe7b5aed915d61fc9da17f7329e7d3d42
Author: Logan Rathbone <poprocks gmail com>
Date: Wed Apr 20 13:59:22 2022 -0400
Initial commit: custom statusbar with monospace support
src/ghex-application-window.c | 29 +++++------------------------
src/ghex-application-window.h | 1 +
src/ghex-application-window.ui.in | 2 +-
src/meson.build | 1 +
4 files changed, 8 insertions(+), 25 deletions(-)
---
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index 563871e..fecd752 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -56,7 +56,6 @@ struct _GHexApplicationWindow
HexDialog *dialog;
GtkWidget *dialog_widget;
GtkCssProvider *conversions_box_provider;
- guint statusbar_id;
GtkAdjustment *adj;
gboolean can_save;
gboolean insert_mode;
@@ -146,7 +145,6 @@ static void ghex_application_window_remove_tab (GHexApplicationWindow *self,
GHexNotebookTab *tab);
static GHexNotebookTab * ghex_application_window_get_current_tab (GHexApplicationWindow *self);
-static void set_statusbar (GHexApplicationWindow *self, const char *str);
static void update_status_message (GHexApplicationWindow *self);
static void update_gui_data (GHexApplicationWindow *self);
static gboolean assess_can_save (HexDocument *doc);
@@ -1432,23 +1430,6 @@ open_preferences (GtkWidget *widget,
/* --- */
-static void
-set_statusbar (GHexApplicationWindow *self, const char *str)
-{
- guint id =
- gtk_statusbar_get_context_id (GTK_STATUSBAR(self->statusbar),
- "status");
-
- gtk_statusbar_pop (GTK_STATUSBAR(self->statusbar), id);
- gtk_statusbar_push (GTK_STATUSBAR(self->statusbar), id, str);
-}
-
-static void
-clear_statusbar (GHexApplicationWindow *self)
-{
- set_statusbar (self, " ");
-}
-
static void
update_status_message (GHexApplicationWindow *self)
{
@@ -1464,19 +1445,19 @@ update_status_message (GHexApplicationWindow *self)
if (hex_widget_get_selection (ACTIVE_GH, &ss, &se))
{
status = g_strdup_printf (
- _("Offset: 0x%lX; 0x%lX bytes from 0x%lX to 0x%lX selected"),
+ _("Offset: <tt>0x%lX</tt>; <tt>0x%lX</tt> bytes from <tt>0x%lX</tt> to
<tt>0x%lX</tt> selected"),
current_pos, se - ss + 1, ss, se);
}
else {
- status = g_strdup_printf (_("Offset: 0x%lX"), current_pos);
+ status = g_strdup_printf (_("Offset: <tt>0x%lX</tt>"), current_pos);
}
- set_statusbar (self, status);
+ hex_statusbar_set_status (HEX_STATUSBAR(self->statusbar), status);
g_free (status);
return;
out:
- clear_statusbar (self);
+ hex_statusbar_clear (HEX_STATUSBAR(self->statusbar));
}
@@ -1691,7 +1672,7 @@ ghex_application_window_init (GHexApplicationWindow *self)
g_signal_connect (self->jump_dialog, "closed",
G_CALLBACK(pane_close_cb), self);
- clear_statusbar (self);
+ hex_statusbar_clear (HEX_STATUSBAR(self->statusbar));
/* Grey out main actions at the beginning */
enable_main_actions (self, FALSE);
diff --git a/src/ghex-application-window.h b/src/ghex-application-window.h
index f5c9c8d..199a16a 100644
--- a/src/ghex-application-window.h
+++ b/src/ghex-application-window.h
@@ -31,6 +31,7 @@
#include "gtkhex.h"
#include "configuration.h"
#include "ghex-notebook-tab.h"
+#include "hex-statusbar.h"
#include "hex-dialog.h"
#include "findreplace.h"
#include "chartable.h"
diff --git a/src/ghex-application-window.ui.in b/src/ghex-application-window.ui.in
index 092228f..4164d7e 100644
--- a/src/ghex-application-window.ui.in
+++ b/src/ghex-application-window.ui.in
@@ -277,7 +277,7 @@
<child>
- <object class="GtkStatusbar" id="statusbar">
+ <object class="HexStatusbar" id="statusbar">
<property name="hexpand">true</property>
</object>
</child>
diff --git a/src/meson.build b/src/meson.build
index 8484274..60c32d9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -76,6 +76,7 @@ ghex_sources = [
'ghex-notebook-tab.c',
'gtkhex-paste-data.c',
'hex-dialog.c',
+ 'hex-statusbar.c',
'main.c',
'paste-special.c',
'preferences.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]