comments.
get rid of the GTK2 support.
Oh, yeah, that's an ABI break. Do we need the new members anywhere
girara_session_s. This wouldn't break the ABI.
if there are any major regressions.
Post by Abdó Roig-MarangesGood night.
Abd?.
From cc858bcb172aa963b7f9b11e01510d56cc23b9ef Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.roig at gmail.com>
Date: Sun, 7 Jul 2013 22:58:26 +0200
Subject: [PATCH 1/3] reorganize widgets from statusbar inputbar and friends
We group the status input notification and completion widgets into a new
bottom_box container.
Also, make sure, particularly in GTK3, that status, input and
notification bars get the same height.
---
completion.c | 2 +-
session.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
session.h | 1 +
statusbar.c | 12 +++++++---
4 files changed, 76 insertions(+), 10 deletions(-)
diff --git a/completion.c b/completion.c
index 030a073..caa975f 100644
--- a/completion.c
+++ b/completion.c
@@ -380,7 +380,7 @@ girara_isc_completion(girara_session_t* session, girara_argument_t* argument, gi
if (entries != NULL) {
entries_current = (argument->n == GIRARA_NEXT) ? g_list_last(entries) : entries;
- gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.results), FALSE, FALSE, 0);
+ gtk_box_pack_start(session->gtk.bottom_box, GTK_WIDGET(session->gtk.results), FALSE, FALSE, 0);
gtk_widget_show(GTK_WIDGET(session->gtk.results));
}
}
diff --git a/session.c b/session.c
index 338ea7a..053a67d 100644
--- a/session.c
+++ b/session.c
@@ -88,11 +88,13 @@ girara_session_create()
/* create widgets */
#if GTK_MAJOR_VERSION == 2
session->gtk.box = GTK_BOX(gtk_vbox_new(FALSE, 0));
+ session->gtk.bottom_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_hbox_new(FALSE, 0));
session->gtk.tabbar = gtk_hbox_new(TRUE, 0);
session->gtk.inputbar_box = GTK_BOX(gtk_hbox_new(TRUE, 0));
#else
session->gtk.box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
+ session->gtk.bottom_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
session->gtk.tabbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
session->gtk.inputbar_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
@@ -216,15 +218,66 @@ girara_session_init(girara_session_t* session, const char* sessionname)
/* notification area */
gtk_container_add(GTK_CONTAINER(session->gtk.notification_area), GTK_WIDGET(session->gtk.notification_text));
- gtk_misc_set_alignment(GTK_MISC(session->gtk.notification_text), 0.0, 0.0);
- gtk_misc_set_padding(GTK_MISC(session->gtk.notification_text), 2, 2);
+ gtk_misc_set_alignment(GTK_MISC(session->gtk.notification_text), 0.0, 0.5);
gtk_label_set_use_markup(GTK_LABEL(session->gtk.notification_text), TRUE);
/* inputbar */
- gtk_entry_set_inner_border(session->gtk.inputbar_entry, NULL);
gtk_entry_set_has_frame(session->gtk.inputbar_entry, FALSE);
gtk_editable_set_editable(GTK_EDITABLE(session->gtk.inputbar_entry), TRUE);
+ /* we want inputbar_entry the same height as notification_text and statusbar,
+ so that when inputbar_entry is hidden, the size of the bottom_box remains
+ the same. We need to get rid of the builtin padding in the GtkEntry
+ widget. */
+
+ guint ypadding = 2; /* total amount of padding (top + bottom) */
+ guint leftpadding = 4; /* left padding */
+
+#if (GTK_MAJOR_VERSION == 3)
+ /* gtk_entry_set_inner_border is deprecated since gtk 3.4 and does nothing. */
+ GtkCssProvider* provider = gtk_css_provider_new();
+ char css[256];
+ const char* css_pattern = "#bottom_box { padding:%dpx 0px %dpx %dpx; }";
+ sprintf(css, css_pattern, ypadding - ypadding/2, ypadding/2, leftpadding);
+
+ gtk_css_provider_load_from_data(provider, css, strlen(css), NULL);
+ GdkDisplay *display = gdk_display_get_default ();
+ GdkScreen *screen = gdk_display_get_default_screen (display);
+ gtk_style_context_add_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+
+ gtk_widget_set_name(session->gtk.inputbar_entry, "bottom_box");
+ gtk_widget_set_name(session->gtk.notification_text, "bottom_box");
+#else
+ // TODO: test this GTK2 block
+ GtkBorder inner_border = {
+ .left = leftpadding,
+ .right = 0,
+ .top = ypadding - ypadding/2,
+ .bottom = ypadding/2
+ };
+
+ gtk_entry_set_inner_border(session->gtk.inputbar_entry, &inner_border);
+
+ /* obtain the actual inputbar height */
+ /* TODO: for some reason does not match */
+ GtkRequisition req;
+ gtk_widget_size_request(GTK_WIDGET(session->gtk.inputbar_entry), &req);
+ /* have no idea where the extra 5 pixels come from. without this, the other
+ widgets get larger than the inputbar */
+ guint statusbar_height = req.height - 5;
+
+ /* force all widgets to have the same height as inputbar */
+ gtk_widget_set_size_request(GTK_WIDGET(session->gtk.inputbar_entry), -1, statusbar_height);
+ gtk_widget_set_size_request(GTK_WIDGET(session->gtk.statusbar_entries), -1, statusbar_height);
+ gtk_widget_set_size_request(GTK_WIDGET(session->gtk.notification_text), -1, statusbar_height);
+
+ /* set horizontal padding. same for statusbar entries in statusbar.c */
+ gtk_misc_set_padding(GTK_MISC(session->gtk.notification_text), leftpadding, 0);
+#endif
+
session->signals.inputbar_key_pressed = g_signal_connect(
G_OBJECT(session->gtk.inputbar_entry),
"key-press-event",
@@ -249,10 +302,18 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_box_set_homogeneous(session->gtk.inputbar_box, FALSE);
gtk_box_set_spacing(session->gtk.inputbar_box, 5);
+ /* inputbar box */
gtk_box_pack_start(GTK_BOX(session->gtk.inputbar_box), GTK_WIDGET(session->gtk.inputbar_dialog), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(session->gtk.inputbar_box), GTK_WIDGET(session->gtk.inputbar_entry), TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(session->gtk.inputbar), GTK_WIDGET(session->gtk.inputbar_box));
+ /* bottom box */
+ gtk_box_set_spacing(session->gtk.bottom_box, 0);
+
+ gtk_box_pack_end(GTK_BOX(session->gtk.bottom_box), GTK_WIDGET(session->gtk.inputbar), TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(session->gtk.bottom_box), GTK_WIDGET(session->gtk.notification_area), TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(session->gtk.bottom_box), GTK_WIDGET(session->gtk.statusbar), TRUE, TRUE, 0);
+
/* tabs */
gtk_notebook_set_show_border(session->gtk.tabs, FALSE);
gtk_notebook_set_show_tabs(session->gtk.tabs, FALSE);
@@ -260,9 +321,7 @@ girara_session_init(girara_session_t* session, const char* sessionname)
/* packing */
gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.tabbar), FALSE, FALSE, 0);
gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.view), TRUE, TRUE, 0);
- gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.statusbar), FALSE, FALSE, 0);
- gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.notification_area), FALSE, FALSE, 0);
- gtk_box_pack_end( session->gtk.box, GTK_WIDGET(session->gtk.inputbar), FALSE, FALSE, 0);
+ gtk_box_pack_end(session->gtk.box, GTK_WIDGET(session->gtk.bottom_box), FALSE, FALSE, 0);
/* parse color values */
typedef struct color_setting_mapping_s
diff --git a/session.h b/session.h
index 5e44f53..bc1c2ca 100644
--- a/session.h
+++ b/session.h
@@ -27,6 +27,7 @@ struct girara_session_s
GtkBox *box; /**< A box that contains all widgets */
GtkWidget *view; /**< The view area of the applications widgets */
GtkWidget *viewport; /**< The viewport of view */
+ GtkBox *bottom_box; /**< Box grouping input, status and notification */
GtkWidget *statusbar; /**< The statusbar */
GtkBox *statusbar_entries; /**< Statusbar entry box */
GtkWidget *notification_area; /**< The notification area */
diff --git a/statusbar.c b/statusbar.c
index 67a1a85..1b8cc2d 100644
--- a/statusbar.c
+++ b/statusbar.c
@@ -25,10 +25,17 @@ girara_statusbar_item_add(girara_session_t* session, bool expand, bool fill, boo
gtk_widget_override_font(GTK_WIDGET(item->text), session->style.font);
/* set properties */
- gtk_misc_set_alignment(GTK_MISC(item->text), left ? 0.0 : 1.0, 0.0);
- gtk_misc_set_padding(GTK_MISC(item->text), 2, 4);
+ gtk_misc_set_alignment(GTK_MISC(item->text), left ? 0.0 : 1.0, 0.5);
gtk_label_set_use_markup(item->text, TRUE);
+#if (GTK_MAJOR_VERSION == 3)
+ /* add name so it uses a custom style */
+ gtk_widget_set_name(item->text, "bottom_box");
+#else
+ /* set padding */
+ gtk_misc_set_padding(GTK_MISC(item->text), 4, 0);
+#endif
+
if (callback != NULL) {
g_signal_connect(G_OBJECT(item->box), "button-press-event", G_CALLBACK(callback), session);
}
@@ -85,4 +92,3 @@ girara_statusbar_set_background(girara_session_t* session, const char* color)
return true;
}
-
--
1.8.3.2
From b90f8b0c572a4e251b6b885ffa249dc7bedd8fe2 Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.roig at gmail.com>
Date: Mon, 8 Jul 2013 00:05:58 +0200
Subject: [PATCH 2/3] make the bottom box an overlay on top of view
On GTK3, we make the bottom_box container that groups status, input
notification and completions, into an overlay on top of the main view.
This means that hiding the inputbar no loger triggers a content resize,
and we will be able, eventually, to get rid of some ugly hacks elsewhere.
---
session.c | 27 +++++++++++++++++++++++----
session.h | 1 +
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/session.c b/session.c
index 053a67d..381b9a3 100644
--- a/session.c
+++ b/session.c
@@ -88,12 +88,14 @@ girara_session_create()
/* create widgets */
#if GTK_MAJOR_VERSION == 2
session->gtk.box = GTK_BOX(gtk_vbox_new(FALSE, 0));
+ session->gtk.overlay = NULL;
session->gtk.bottom_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_hbox_new(FALSE, 0));
session->gtk.tabbar = gtk_hbox_new(TRUE, 0);
session->gtk.inputbar_box = GTK_BOX(gtk_hbox_new(TRUE, 0));
#else
session->gtk.box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
+ session->gtk.overlay = gtk_overlay_new();
session->gtk.bottom_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
session->gtk.tabbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
@@ -209,10 +211,6 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_widget_modify_bg(GTK_WIDGET(session->gtk.viewport), GTK_STATE_NORMAL, &(session->style.default_background));
#endif
- /* box */
- gtk_box_set_spacing(session->gtk.box, 0);
- gtk_container_add(GTK_CONTAINER(session->gtk.window), GTK_WIDGET(session->gtk.box));
-
/* statusbar */
gtk_container_add(GTK_CONTAINER(session->gtk.statusbar), GTK_WIDGET(session->gtk.statusbar_entries));
@@ -318,11 +316,32 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_notebook_set_show_border(session->gtk.tabs, FALSE);
gtk_notebook_set_show_tabs(session->gtk.tabs, FALSE);
+#if (GTK_MAJOR_VERSION == 3)
/* packing */
+ gtk_box_set_spacing(session->gtk.box, 0);
+ gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.tabbar), FALSE, FALSE, 0);
+ gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.view), TRUE, TRUE, 0);
+
+ /* box */
+ gtk_container_add(GTK_CONTAINER(session->gtk.overlay), GTK_WIDGET(session->gtk.box));
+ /* overlay */
+ g_object_set(session->gtk.bottom_box, "halign", GTK_ALIGN_FILL, NULL);
+ g_object_set(session->gtk.bottom_box, "valign", GTK_ALIGN_END, NULL);
+
+ gtk_overlay_add_overlay(GTK_OVERLAY(session->gtk.overlay), GTK_WIDGET(session->gtk.bottom_box));
+ gtk_container_add(GTK_CONTAINER(session->gtk.window), GTK_WIDGET(session->gtk.overlay));
+
+#else
+ /* packing */
+ gtk_box_set_spacing(session->gtk.box, 0);
gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.tabbar), FALSE, FALSE, 0);
gtk_box_pack_start(session->gtk.box, GTK_WIDGET(session->gtk.view), TRUE, TRUE, 0);
gtk_box_pack_end(session->gtk.box, GTK_WIDGET(session->gtk.bottom_box), FALSE, FALSE, 0);
+ /* box */
+ gtk_container_add(GTK_CONTAINER(session->gtk.window), GTK_WIDGET(session->gtk.box));
+#endif
+
/* parse color values */
typedef struct color_setting_mapping_s
{
diff --git a/session.h b/session.h
index bc1c2ca..a50d04d 100644
--- a/session.h
+++ b/session.h
@@ -27,6 +27,7 @@ struct girara_session_s
GtkBox *box; /**< A box that contains all widgets */
GtkWidget *view; /**< The view area of the applications widgets */
GtkWidget *viewport; /**< The viewport of view */
+ GtkWidget *overlay; /**< So we can overlay bottom_box on top of view */
GtkBox *bottom_box; /**< Box grouping input, status and notification */
GtkWidget *statusbar; /**< The statusbar */
GtkBox *statusbar_entries; /**< Statusbar entry box */
--
1.8.3.2
From 4c0747ab9db0ca9be0b7c6d0f9b7a9b14495584b Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.roig at gmail.com>
Date: Mon, 8 Jul 2013 01:36:47 +0200
Subject: [PATCH 3/3] add a configuration setting for statusbar vertical
padding
---
config.c | 2 ++
session.c | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index 5910d43..e14df33 100644
--- a/config.c
+++ b/config.c
@@ -184,6 +184,7 @@ girara_config_load_default(girara_session_t* session)
}
/* values */
+ int statusbar_padding = 2;
int window_width = 800;
int window_height = 600;
int n_completion_items = 15;
@@ -220,6 +221,7 @@ girara_config_load_default(girara_session_t* session)
girara_setting_add(session, "word-separator", " /.-=&#?", STRING, TRUE, NULL, NULL, NULL);
girara_setting_add(session, "window-width", &window_width, INT, TRUE, _("Initial window width"), NULL, NULL);
girara_setting_add(session, "window-height", &window_height, INT, TRUE, _("Initial window height"), NULL, NULL);
+ girara_setting_add(session, "statusbar-padding", &statusbar_padding, INT, TRUE, _("Vertical padding for the status input and notification bars"), NULL, NULL);
girara_setting_add(session, "n-completion-items", &n_completion_items, INT, TRUE, _("Number of completion items"), NULL, NULL);
girara_setting_add(session, "show-scrollbars", &show_scrollbars, BOOLEAN, FALSE, _("Show both the horizontal and vertical scrollbars"), cb_scrollbars, NULL);
girara_setting_add(session, "show-h-scrollbar", &show_scrollbars, BOOLEAN, FALSE, _("Show the horizontal scrollbar"), cb_scrollbars, NULL);
diff --git a/session.c b/session.c
index 381b9a3..dde197b 100644
--- a/session.c
+++ b/session.c
@@ -228,8 +228,9 @@ girara_session_init(girara_session_t* session, const char* sessionname)
the same. We need to get rid of the builtin padding in the GtkEntry
widget. */
- guint ypadding = 2; /* total amount of padding (top + bottom) */
- guint leftpadding = 4; /* left padding */
+ guint ypadding = 2; /* total amount of padding (top + bottom) */
+ guint leftpadding = 4; /* left padding */
+ girara_setting_get(session, "statusbar-padding", &ypadding);
#if (GTK_MAJOR_VERSION == 3)
/* gtk_entry_set_inner_border is deprecated since gtk 3.4 and does nothing. */
--
1.8.3.2
_______________________________________________
zathura mailing list
zathura at lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura