summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnarky2018-07-13 09:12:16 +0200
committerAnarky2018-07-13 09:12:16 +0200
commit3d8bcb6640fd87e768923e468a7680ee7d59b3b6 (patch)
tree7e84c9d6abd0686a633635153bd9210d36127267
downloadaur-gtk3-libwinmenu.tar.gz
gtk3-libwinmenu: import from AUR Archive, fix PKGBUILD, change key, update to gtk3
-rw-r--r--.SRCINFO21
-rw-r--r--Makefile2
-rw-r--r--PKGBUILD31
-rw-r--r--libwinmenu.c84
-rw-r--r--libwinmenu.install6
-rw-r--r--update_to_gtk3.patch34
-rw-r--r--use_alt_left.patch12
7 files changed, 190 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..1f36d8221a7
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,21 @@
+pkgbase = gtk3-libwinmenu
+ pkgdesc = Gtk+ module to hide menubar by default
+ pkgver = 1
+ pkgrel = 1
+ url = http://www.linux.org.ru/jump-message.jsp?msgid=5606544&cid=5617512
+ install = libwinmenu.install
+ arch = i686
+ arch = x86_64
+ license = custom
+ depends = gtk3
+ source = libwinmenu.c
+ source = Makefile
+ source = use_alt_left.patch
+ source = update_to_gtk3.patch
+ md5sums = 20a2e4823e8d2baf1e33de97335a040b
+ md5sums = f90fd2c86b796a0c9d9e4a646539ec31
+ md5sums = d43683a6001d8032881f95ccf8dda5f4
+ md5sums = f2bc0a86ed0d394a6e6725fc26010b44
+
+pkgname = gtk3-libwinmenu
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000000..d1fe60799e9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+all:
+ gcc -shared -fPIC `pkg-config gtk+-x11-2.0 --cflags --libs` -o libwinmenu.so libwinmenu.c
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..80cb61c979d
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,31 @@
+pkgname=gtk3-libwinmenu
+pkgver=1
+pkgrel=1
+pkgdesc="Gtk+ module to hide menubar by default"
+arch=('i686' 'x86_64')
+url='http://www.linux.org.ru/jump-message.jsp?msgid=5606544&cid=5617512'
+license=('custom')
+depends=('gtk3')
+source=('libwinmenu.c' 'Makefile'
+ use_alt_left.patch
+ update_to_gtk3.patch)
+md5sums=('20a2e4823e8d2baf1e33de97335a040b' 'f90fd2c86b796a0c9d9e4a646539ec31'
+ d43683a6001d8032881f95ccf8dda5f4
+ f2bc0a86ed0d394a6e6725fc26010b44)
+install='libwinmenu.install'
+
+prepare() {
+ cd "$srcdir"
+ patch -Np1 --follow-symlinks -i use_alt_left.patch
+ patch -Np1 --follow-symlinks -i update_to_gtk3.patch
+}
+
+build() {
+ cd "$srcdir"
+ make
+}
+
+package() {
+ cd "$srcdir"
+ install -Dm755 libwinmenu.so "$pkgdir/usr/lib/gtk-3.0/modules/libwinmenu.so"
+}
diff --git a/libwinmenu.c b/libwinmenu.c
new file mode 100644
index 00000000000..0cc2ae06577
--- /dev/null
+++ b/libwinmenu.c
@@ -0,0 +1,84 @@
+/*
+ * gcc -shared `pkg-config gtk+-x11-2.0 --cflags --libs` -o libwinmenu.so main.c
+ * */
+
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#define _gtk_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
+#define _gtk_marshal_NONE__NONE _gtk_marshal_VOID__VOID
+
+static GObject* (*old_gtk_menu_bar_constructor)(GType type, guint n_construct_properties, GObjectConstructParam *construct_params) = NULL;
+static GObject* (*old_gtk_window_constructor)(GType type, guint n_construct_properties, GObjectConstructParam *construct_params) = NULL;
+static void (*old_widget_show) (GtkWidget * widget) = NULL;
+
+static void toggle_menu_bar (GtkWidget *widget, gpointer user_data)
+{
+ GtkWidget * wdg = GTK_WIDGET(user_data);
+ GTK_WIDGET_GET_CLASS(wdg)->show = old_widget_show;
+ if (GTK_WIDGET_VISIBLE(wdg))
+ gtk_widget_hide(wdg);
+ else
+ gtk_widget_show(wdg);
+}
+
+static void anchor_event (GtkWidget *widget, GtkWidget *previous_toplevel, gpointer user_data)
+{
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+ if (GTK_WIDGET_TOPLEVEL (toplevel)) {
+ if (previous_toplevel)
+ g_signal_handlers_disconnect_by_func(previous_toplevel, G_CALLBACK(toggle_menu_bar), widget);
+ g_signal_connect (toplevel, "toggle-menu-bar", G_CALLBACK(toggle_menu_bar), widget);
+ }
+}
+
+static void show (GtkWidget *widget)
+{
+ if (GTK_IS_MENU_BAR(widget))
+ return;
+ old_widget_show(widget);
+}
+
+GObject* new_gtk_menu_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params)
+{
+ GObject * ret = old_gtk_menu_bar_constructor(type,n_construct_properties,construct_params);
+ g_signal_connect (ret, "hierarchy-changed", G_CALLBACK(anchor_event), NULL);
+ g_signal_connect (ret, "can_activate_accel", G_CALLBACK(gtk_true), NULL);
+
+ return ret;
+}
+
+G_MODULE_EXPORT void
+gtk_module_init (gint * argc, gchar *** argv)
+{
+ GtkWidget *fc;
+ GObjectClass *klass;
+ const gchar *app_whitelist = "gnome-terminal, gimp, mousepad";
+
+ if (strstr (app_whitelist, g_get_prgname()) != NULL)
+ return;
+
+ g_signal_new ("toggle-menu-bar",
+ GTK_TYPE_WINDOW,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ fc = gtk_menu_bar_new();
+ klass = GTK_MENU_BAR_GET_CLASS(fc);
+ old_gtk_menu_bar_constructor = klass->constructor;
+ klass->constructor = new_gtk_menu_bar_constructor;
+ old_widget_show = GTK_WIDGET_CLASS(klass)->show;
+ GTK_WIDGET_CLASS(klass)->show = show;
+
+ fc = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ klass = GTK_WINDOW_GET_CLASS(fc);
+
+ gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_m, GDK_CONTROL_MASK,
+ "toggle-menu-bar", 0);
+ gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_m, GDK_MOD1_MASK,
+ "toggle-menu-bar", 0);
+}
diff --git a/libwinmenu.install b/libwinmenu.install
new file mode 100644
index 00000000000..a488da1d6d9
--- /dev/null
+++ b/libwinmenu.install
@@ -0,0 +1,6 @@
+post_install() {
+ echo "Set the following environment variable for changes to take place"
+ echo "GTK_MODULES=winmenu"
+ echo "----------------------------------------------------------------"
+ echo "Menu is toggled with Alt"
+}
diff --git a/update_to_gtk3.patch b/update_to_gtk3.patch
new file mode 100644
index 00000000000..99964b7c758
--- /dev/null
+++ b/update_to_gtk3.patch
@@ -0,0 +1,34 @@
+--- a/Makefile
++++ b/Makefile
+@@ -1,2 +1,2 @@
+ all:
+- gcc -shared -fPIC `pkg-config gtk+-x11-2.0 --cflags --libs` -o libwinmenu.so libwinmenu.c
++ gcc -shared -fPIC `pkg-config gtk+-x11-3.0 --cflags --libs` -o libwinmenu.so libwinmenu.c
+--- a/libwinmenu.c
++++ b/libwinmenu.c
+@@ -16,7 +16,7 @@ static void toggle_menu_bar (GtkWidget *widget, gpointer user_data)
+ {
+ GtkWidget * wdg = GTK_WIDGET(user_data);
+ GTK_WIDGET_GET_CLASS(wdg)->show = old_widget_show;
+- if (GTK_WIDGET_VISIBLE(wdg))
++ if (gtk_widget_get_visible(wdg))
+ gtk_widget_hide(wdg);
+ else
+ gtk_widget_show(wdg);
+@@ -25,7 +25,7 @@ static void toggle_menu_bar (GtkWidget *widget, gpointer user_data)
+ static void anchor_event (GtkWidget *widget, GtkWidget *previous_toplevel, gpointer user_data)
+ {
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+- if (GTK_WIDGET_TOPLEVEL (toplevel)) {
++ if (gtk_widget_is_toplevel (toplevel)) {
+ if (previous_toplevel)
+ g_signal_handlers_disconnect_by_func(previous_toplevel, G_CALLBACK(toggle_menu_bar), widget);
+ g_signal_connect (toplevel, "toggle-menu-bar", G_CALLBACK(toggle_menu_bar), widget);
+@@ -77,6 +77,6 @@ gtk_module_init (gint * argc, gchar *** argv)
+ fc = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ klass = GTK_WINDOW_GET_CLASS(fc);
+
+- gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_Alt_L, 0,
++ gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_KEY_Alt_L, 0,
+ "toggle-menu-bar", 0);
+ }
diff --git a/use_alt_left.patch b/use_alt_left.patch
new file mode 100644
index 00000000000..47a6d3f4c6d
--- /dev/null
+++ b/use_alt_left.patch
@@ -0,0 +1,12 @@
+--- a/libwinmenu.c
++++ b/libwinmenu.c
+@@ -77,8 +77,6 @@ gtk_module_init (gint * argc, gchar *** argv)
+ fc = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ klass = GTK_WINDOW_GET_CLASS(fc);
+
+- gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_m, GDK_CONTROL_MASK,
+- "toggle-menu-bar", 0);
+- gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_m, GDK_MOD1_MASK,
++ gtk_binding_entry_add_signal (gtk_binding_set_by_class (klass), GDK_Alt_L, 0,
+ "toggle-menu-bar", 0);
+ }