aboutsummaryrefslogtreecommitdiff
path: root/libtopmenu-client
diff options
context:
space:
mode:
Diffstat (limited to 'libtopmenu-client')
-rw-r--r--libtopmenu-client/Makefile.am21
-rw-r--r--libtopmenu-client/topmenu-appmenubar.c32
-rw-r--r--libtopmenu-client/topmenu-client.c6
-rw-r--r--libtopmenu-client/topmenu-monitor.c2
4 files changed, 53 insertions, 8 deletions
diff --git a/libtopmenu-client/Makefile.am b/libtopmenu-client/Makefile.am
index b57343b..f4f8b6f 100644
--- a/libtopmenu-client/Makefile.am
+++ b/libtopmenu-client/Makefile.am
@@ -1,8 +1,21 @@
-lib_LTLIBRARIES = libtopmenu-client.la
-libtopmenu_client_la_SOURCES = topmenu-client.c topmenu-client.h \
+if GTK3
+
+lib_LTLIBRARIES = libtopmenu-client-gtk3.la
+libtopmenu_client_gtk3_la_SOURCES = topmenu-client.c topmenu-client.h \
+ topmenu-monitor.c topmenu-monitor.h \
+ topmenu-appmenubar.c topmenu-appmenubar.h
+libtopmenu_client_gtk3_la_CPPFLAGS = $(GTK_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-client\"
+libtopmenu_client_gtk3_la_LIBADD = $(GTK_LIBS)
+
+else
+
+lib_LTLIBRARIES = libtopmenu-client-gtk2.la
+libtopmenu_client_gtk2_la_SOURCES = topmenu-client.c topmenu-client.h \
topmenu-monitor.c topmenu-monitor.h \
topmenu-appmenubar.c topmenu-appmenubar.h
-libtopmenu_client_la_CPPFLAGS = $(GTK_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-client\"
-libtopmenu_client_la_LIBADD = $(GTK_LIBS)
+libtopmenu_client_gtk2_la_CPPFLAGS = $(GTK_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-client\"
+libtopmenu_client_gtk2_la_LIBADD = $(GTK_LIBS)
+
+endif
include_HEADERS = topmenu-client.h topmenu-monitor.h topmenu-appmenubar.h
diff --git a/libtopmenu-client/topmenu-appmenubar.c b/libtopmenu-client/topmenu-appmenubar.c
index 7d94cf5..5c66d91 100644
--- a/libtopmenu-client/topmenu-appmenubar.c
+++ b/libtopmenu-client/topmenu-appmenubar.c
@@ -48,6 +48,7 @@ static void topmenu_app_menu_bar_class_init(TopMenuAppMenuBarClass *klass)
g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+#if GTK_MAJOR_VERSION == 2
gtk_rc_parse_string (
"style \"app-menubar-style\"\n"
"{\n"
@@ -55,10 +56,41 @@ static void topmenu_app_menu_bar_class_init(TopMenuAppMenuBarClass *klass)
" GtkMenuBar::internal-padding = 0\n"
"}\n"
"class \"TopMenuAppMenuBar\" style \"app-menubar-style\"");
+#endif
}
static void topmenu_app_menu_bar_init(TopMenuAppMenuBar *self)
{
+#if GTK_MAJOR_VERSION == 3
+ GError *error = NULL;
+ GtkCssProvider *provider = gtk_css_provider_new();
+ GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(self));
+ static const char *css =
+ "TopMenuAppMenuBar {\n"
+ " box-shadow: none;\n"
+ " padding: 0;\n"
+ " background-color: @os_chrome_bg_color;\n"
+ " background-image: none;\n"
+ " color: @os_chrome_fg_color;\n"
+ "}\n"
+ "\n"
+ "TopMenuAppMenuBar .menu .menuitem *:active {\n"
+ " color: @theme_text_color;\n"
+ "}\n"
+ "\n"
+ "TopMenuAppMenuBar .menu .menuitem *:selected {\n"
+ " color: @theme_selected_fg_color;\n"
+ "}\n";
+ if (gtk_css_provider_load_from_data(provider, css, -1, &error)) {
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ g_warning("Error while loading CSS: %s", error->message);
+ g_error_free(error);
+ }
+#endif
+
self->app_menu_item = GTK_MENU_ITEM(gtk_menu_item_new_with_label(g_get_application_name()));
GtkLabel *app_label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(self->app_menu_item)));
PangoAttrList *app_label_attr = pango_attr_list_new();
diff --git a/libtopmenu-client/topmenu-client.c b/libtopmenu-client/topmenu-client.c
index f7d3e58..cbc2d20 100644
--- a/libtopmenu-client/topmenu-client.c
+++ b/libtopmenu-client/topmenu-client.c
@@ -43,7 +43,7 @@ static gboolean handle_widget_button_event(GtkWidget *widget, GdkEvent *event, G
e.type = event->type == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease;
e.xbutton.window = xwin;
e.xbutton.display = dpy;
- e.xbutton.root = GDK_WINDOW_XWINDOW(root);
+ e.xbutton.root = gdk_x11_window_get_xid(root);
e.xbutton.time = event->button.time;
e.xbutton.button = event->button.button;
e.xbutton.state = event->button.state;
@@ -76,7 +76,7 @@ void topmenu_client_connect_window_widget(GdkWindow *window, GtkWidget *widget)
topmenu_client_disconnect_window(window);
}
- Window xwin = GDK_WINDOW_XID(window);
+ Window xwin = gdk_x11_window_get_xid(window);
GtkPlug *plug = GTK_PLUG(gtk_plug_new(0));
gtk_container_add(GTK_CONTAINER(plug), widget);
g_signal_connect_object(plug, "delete-event",
@@ -110,7 +110,7 @@ void topmenu_client_disconnect_window(GdkWindow *window)
gpointer window_data = g_object_steal_data(G_OBJECT(window), OBJECT_DATA_KEY_PLUG);
g_return_if_fail(window_data);
- Window xwin = GDK_WINDOW_XID(window);
+ Window xwin = gdk_x11_window_get_xid(window);
GtkPlug *plug = GTK_PLUG(window_data);
g_return_if_fail(plug);
diff --git a/libtopmenu-client/topmenu-monitor.c b/libtopmenu-client/topmenu-monitor.c
index 2f63e9b..94302ef 100644
--- a/libtopmenu-client/topmenu-monitor.c
+++ b/libtopmenu-client/topmenu-monitor.c
@@ -110,7 +110,7 @@ static void topmenu_monitor_dispose(GObject *obj)
if (self->priv->cur_server) {
gdk_window_remove_filter(self->priv->cur_server,
handle_cur_server_event, self);
- gdk_window_unref(self->priv->cur_server);
+ g_object_unref(self->priv->cur_server);
self->priv->cur_server = 0;
}
self->priv->selection = NULL;