Commit 0c7bafd1 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Fix scrollbar handling for 3.20

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 5372d0ad
/* Hide scrollbars from GtkScrolledWindow */
#@session@ scrolledwindow scrollbar:disabled > slider {
min-width: 0;
}
#@session@ scrolledwindow scrollbar:disabled > through {
margin: 0;
}
#@session@ scrolledwindow scrollbar {
background-color: @scrollbar-bg@;
}
......
......@@ -106,23 +106,8 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
gtk_widget_hide(session->gtk.statusbar);
}
GtkWidget* vscrollbar = gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(session->gtk.view));
GtkWidget* hscrollbar = gtk_scrolled_window_get_hscrollbar(GTK_SCROLLED_WINDOW(session->gtk.view));
if (vscrollbar != NULL) {
if (show_vscrollbar == true) {
gtk_widget_unset_state_flags(vscrollbar, GTK_STATE_FLAG_INSENSITIVE);
} else {
gtk_widget_set_state_flags(vscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
}
if (hscrollbar != NULL) {
if (show_hscrollbar == true) {
gtk_widget_unset_state_flags(hscrollbar, GTK_STATE_FLAG_INSENSITIVE);
} else {
gtk_widget_set_state_flags(hscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
}
scrolled_window_set_scrollbar_visibility(
GTK_SCROLLED_WINDOW(session->gtk.view), show_hscrollbar, show_vscrollbar);
}
static void
......
......@@ -54,6 +54,10 @@ HIDDEN void widget_add_class(GtkWidget* widget, const char* styleclass);
HIDDEN void widget_remove_class(GtkWidget* widget, const char* styleclass);
HIDDEN void scrolled_window_set_scrollbar_visibility(GtkScrolledWindow* window,
bool show_horizontal,
bool show_vertical);
/**
* Default complection function for the settings
*
......
......@@ -205,6 +205,48 @@ css_template_changed(GiraraTemplate* csstemplate, girara_session_t* session)
session->private_data->gtk.cssprovider = provider;
}
void
scrolled_window_set_scrollbar_visibility(GtkScrolledWindow* window,
bool show_horizontal,
bool show_vertical)
{
#if GTK_CHECK_VERSION(3, 16, 0)
if (gtk_check_version(3, 16, 0) == NULL) {
GtkPolicyType hpolicy = GTK_POLICY_AUTOMATIC;
GtkPolicyType vpolicy = GTK_POLICY_AUTOMATIC;
if (show_horizontal == false) {
hpolicy = GTK_POLICY_EXTERNAL;
}
if (show_vertical == false) {
vpolicy = GTK_POLICY_EXTERNAL;
}
gtk_scrolled_window_set_policy(window, hpolicy, vpolicy);
return;
}
#endif
GtkWidget* vscrollbar = gtk_scrolled_window_get_vscrollbar(window);
GtkWidget* hscrollbar = gtk_scrolled_window_get_hscrollbar(window);
if (vscrollbar != NULL) {
if (show_vertical == true) {
gtk_widget_unset_state_flags(vscrollbar, GTK_STATE_FLAG_INSENSITIVE);
} else {
gtk_widget_set_state_flags(vscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
}
if (hscrollbar != NULL) {
if (show_horizontal == true) {
gtk_widget_unset_state_flags(hscrollbar, GTK_STATE_FLAG_INSENSITIVE);
} else {
gtk_widget_set_state_flags(hscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
}
}
girara_session_t*
girara_session_create()
{
......@@ -360,20 +402,14 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(session->gtk.view), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
/* invisible scrollbars */
GtkWidget *vscrollbar = gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(session->gtk.view));
GtkWidget *hscrollbar = gtk_scrolled_window_get_hscrollbar(GTK_SCROLLED_WINDOW(session->gtk.view));
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
if (vscrollbar != NULL && strchr(guioptions, 'v') == NULL) {
gtk_widget_set_state_flags(vscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
if (hscrollbar != NULL) {
if (strchr(guioptions, 'h') == NULL) {
gtk_widget_set_state_flags(hscrollbar, GTK_STATE_FLAG_INSENSITIVE, false);
}
}
const bool show_hscrollbar = strchr(guioptions, 'h') != NULL;
const bool show_vscrollbar = strchr(guioptions, 'v') != NULL;
scrolled_window_set_scrollbar_visibility(
GTK_SCROLLED_WINDOW(session->gtk.view), show_hscrollbar, show_vscrollbar);
g_free(guioptions);
/* viewport */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment