aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-gtk
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-02 09:10:38 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-02 09:10:38 +0100
commit8627a00e3b25cdd80d88ddcef9d2d73cc784d571 (patch)
treed52eb248e7258f6aec7c29caafa0b202e9b2f9c5 /src/interface-gtk
parentf25f97e4d0d9a1da69d0ee8fc4fbdff70760f805 (diff)
downloadsciteco-8627a00e3b25cdd80d88ddcef9d2d73cc784d571.tar.gz
Gtk UI: added option --no-csd to disable client-side decorations
* many WMs like Unity or even Awesome WM have problems with client-side decorations. Awesome WM for instance does not allow us to move or resize floating windows with CSDs. Also, the added close button does not make sense for tiling window managers and since they usually never show window title bars, CSD brings no advantages at all on tiling window managers. * Other window managers might not support CSD at all. * There is AFAIK no way to detect whether CSDs will be possible or whether there will be glitches (see Awesome). * Added command line option --no-csd in the --help-gtk group. This can be added to desktop shortcuts etc. Later there might be better ways to configure stuff like that, e.g. when we add support for scripted UI customizations.
Diffstat (limited to 'src/interface-gtk')
-rw-r--r--src/interface-gtk/interface-gtk.cpp34
-rw-r--r--src/interface-gtk/interface-gtk.h8
2 files changed, 31 insertions, 11 deletions
diff --git a/src/interface-gtk/interface-gtk.cpp b/src/interface-gtk/interface-gtk.cpp
index 1babdff..ebd3c91 100644
--- a/src/interface-gtk/interface-gtk.cpp
+++ b/src/interface-gtk/interface-gtk.cpp
@@ -131,6 +131,22 @@ ViewGtk::initialize_impl(void)
setup();
}
+GOptionGroup *
+InterfaceGtk::get_options(void)
+{
+ const GOptionEntry entries[] = {
+ {"no-csd", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &use_csd,
+ "Disable client-side decorations.", NULL},
+ {NULL}
+ };
+
+ GOptionGroup *group = gtk_get_option_group(TRUE);
+
+ g_option_group_add_entries(group, entries);
+
+ return group;
+}
+
void
InterfaceGtk::main_impl(int &argc, char **&argv)
{
@@ -166,17 +182,23 @@ InterfaceGtk::main_impl(int &argc, char **&argv)
/*
* The info bar is tried to be made the title bar of the
* window which also disables the default window decorations
- * (client-side decorations).
- * FIXME: This could fail, leaving us with a standard title
- * bar and the info bar with close buttons. In this case,
- * we should at least disable the info bar close button.
+ * (client-side decorations) unless --no-csd was specified.
+ * NOTE: Client-side decoations could fail, leaving us with a
+ * standard title bar and the info bar with close buttons.
+ * Other window managers have undesirable side-effects.
* FIXME: At lease on Gtk 3.12 we could disable the subtitle.
*/
info_bar_widget = gtk_header_bar_new();
- gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(info_bar_widget), TRUE);
info_image = gtk_image_new();
gtk_header_bar_pack_start(GTK_HEADER_BAR(info_bar_widget), info_image);
- gtk_window_set_titlebar(GTK_WINDOW(window), info_bar_widget);
+ if (use_csd) {
+ /* use client-side decorations */
+ gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(info_bar_widget), TRUE);
+ gtk_window_set_titlebar(GTK_WINDOW(window), info_bar_widget);
+ } else {
+ /* fall back to adding the info bar as an ordinary widget */
+ gtk_box_pack_start(GTK_BOX(vbox), info_bar_widget, FALSE, FALSE, 0);
+ }
/*
* The event box is the parent of all Scintilla views
diff --git a/src/interface-gtk/interface-gtk.h b/src/interface-gtk/interface-gtk.h
index a3a0af6..4563d5f 100644
--- a/src/interface-gtk/interface-gtk.h
+++ b/src/interface-gtk/interface-gtk.h
@@ -84,6 +84,7 @@ typedef class InterfaceGtk : public Interface<InterfaceGtk, ViewGtk> {
INFO_TYPE_QREGISTER
} info_type;
gchar *info_current;
+ gboolean use_csd;
GtkWidget *info_bar_widget;
GtkWidget *info_image;
@@ -105,6 +106,7 @@ public:
window(NULL),
vbox(NULL),
info_type(INFO_TYPE_BUFFER), info_current(NULL),
+ use_csd(TRUE),
info_bar_widget(NULL), info_image(NULL),
event_box_widget(NULL),
message_bar_widget(NULL), message_widget(NULL),
@@ -115,11 +117,7 @@ public:
~InterfaceGtk();
/* overrides Interface::get_options() */
- inline GOptionGroup *
- get_options(void)
- {
- return gtk_get_option_group(TRUE);
- }
+ GOptionGroup *get_options(void);
/* implementation of Interface::main() */
void main_impl(int &argc, char **&argv);