diff options
author | Stefano Karapetsas <[email protected]> | 2013-10-26 14:40:30 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-10-26 14:40:30 +0200 |
commit | 0b2f11a6390b704e85157c2a800643dcde0f714c (patch) | |
tree | 5e9b1ed30be22d5546f02136ca8db6f9fef2f1bb | |
parent | 5c99612305a3042d7096123619a83346492eadf3 (diff) | |
download | mate-panel-0b2f11a6390b704e85157c2a800643dcde0f714c.tar.bz2 mate-panel-0b2f11a6390b704e85157c2a800643dcde0f714c.tar.xz |
wncklet: Add GTK3 support
-rw-r--r-- | applets/wncklet/showdesktop.c | 3 | ||||
-rw-r--r-- | applets/wncklet/window-list.c | 47 | ||||
-rw-r--r-- | applets/wncklet/window-menu.c | 36 | ||||
-rw-r--r-- | applets/wncklet/wncklet.c | 4 | ||||
-rw-r--r-- | applets/wncklet/wncklet.h | 2 | ||||
-rw-r--r-- | applets/wncklet/workspace-switcher.c | 47 |
6 files changed, 113 insertions, 26 deletions
diff --git a/applets/wncklet/showdesktop.c b/applets/wncklet/showdesktop.c index 3b961745..bdf4d568 100644 --- a/applets/wncklet/showdesktop.c +++ b/applets/wncklet/showdesktop.c @@ -30,7 +30,8 @@ #include <gtk/gtk.h> #include <gdk/gdkx.h> -#include <libwnck/screen.h> +#define WNCK_I_KNOW_THIS_IS_UNSTABLE +#include <libwnck/libwnck.h> #include "wncklet.h" #include "showdesktop.h" diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c index 60b0b177..e24d6eb6 100644 --- a/applets/wncklet/window-list.c +++ b/applets/wncklet/window-list.c @@ -19,9 +19,15 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> +#define WNCK_I_KNOW_THIS_IS_UNSTABLE #include <libwnck/libwnck.h> #include <gio/gio.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-desktop-utils.h> +#endif + #include "wncklet.h" #include "window-list.h" @@ -55,7 +61,7 @@ typedef struct { GSettings* settings; } TasklistData; -static void callSystemMonitor(GtkAction* action, TasklistData* tasklist); +static void call_system_monitor(GtkAction* action, TasklistData* tasklist); static void display_properties_dialog(GtkAction* action, TasklistData* tasklist); static void display_help_dialog(GtkAction* action, TasklistData* tasklist); static void display_about_dialog(GtkAction* action, TasklistData* tasklist); @@ -121,7 +127,11 @@ static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient tasklist_update(tasklist); } +#if GTK_CHECK_VERSION (3, 0, 0) +static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t* pattern, TasklistData* tasklist) +#else static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, TasklistData* tasklist) +#endif { switch (type) { @@ -157,7 +167,7 @@ static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist) /* TODO: this is sad, should be used a function to retrieve applications from * .desktop or some like that. */ -static const char* listOfSystemMonitors[] = { +static const char* system_monitors[] = { "mate-system-monitor", "gnome-system-monitor", }; @@ -169,7 +179,7 @@ static const GtkActionEntry tasklist_menu_actions[] = { N_("_System Monitor"), NULL, NULL, - G_CALLBACK(callSystemMonitor) + G_CALLBACK(call_system_monitor) }, { "TasklistPreferences", @@ -415,7 +425,11 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) break; } +#if WNCK_CHECK_VERSION (2, 91, 6) + tasklist->tasklist = wnck_tasklist_new(); +#else tasklist->tasklist = wnck_tasklist_new(NULL); +#endif #if WNCK_CHECK_VERSION (3, 4, 6) wnck_tasklist_set_orientation (tasklist->tasklist, tasklist->orientation); @@ -448,9 +462,9 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) char* programpath; int i; - for (i = 0; i < G_N_ELEMENTS(listOfSystemMonitors); i += 1) + for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1) { - programpath = g_find_program_in_path(listOfSystemMonitors[i]); + programpath = g_find_program_in_path(system_monitors[i]); if (programpath != NULL) { @@ -488,26 +502,33 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) return TRUE; } -static void callSystemMonitor(GtkAction* action, TasklistData* tasklist) +static void call_system_monitor(GtkAction* action, TasklistData* tasklist) { +#if !GTK_CHECK_VERSION (3, 0, 0) char* argv[2] = {NULL, NULL}; +#endif char* programpath; int i; - for (i = 0; i < G_N_ELEMENTS(listOfSystemMonitors); i += 1) + for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1) { - programpath = g_find_program_in_path(listOfSystemMonitors[i]); - + programpath = g_find_program_in_path(system_monitors[i]); + if (programpath != NULL) { g_free(programpath); - - argv[0] = listOfSystemMonitors[i]; - + +#if GTK_CHECK_VERSION (3, 0, 0) + mate_gdk_spawn_command_line_on_screen(gtk_widget_get_screen(tasklist->applet), + system_monitors[i], + NULL); +#else + argv[0] = system_monitors[i]; gdk_spawn_on_screen(gtk_widget_get_screen(tasklist->applet), NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); - +#endif + return; } } diff --git a/applets/wncklet/window-menu.c b/applets/wncklet/window-menu.c index b3133946..cef49657 100644 --- a/applets/wncklet/window-menu.c +++ b/applets/wncklet/window-menu.c @@ -34,8 +34,12 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkkeysyms-compat.h> +#endif -#include <libwnck/selector.h> +#define WNCK_I_KNOW_THIS_IS_UNSTABLE +#include <libwnck/libwnck.h> #include "wncklet.h" #include "window-menu.h" @@ -115,12 +119,34 @@ static void window_menu_destroy(GtkWidget* widget, WindowMenu* window_menu) g_free(window_menu); } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean window_menu_on_draw(GtkWidget* widget, cairo_t* cr, gpointer data) +#else static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data) +#endif { WindowMenu* window_menu = data; if (gtk_widget_has_focus(window_menu->applet)) - gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(widget), NULL, widget, "menu-applet", 0, 0, -1, -1); + gtk_paint_focus(gtk_widget_get_style(widget), +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + gtk_widget_get_window(widget), +#endif + gtk_widget_get_state(widget), +#if !GTK_CHECK_VERSION (3, 0, 0) + NULL, +#endif + widget, + "menu-applet", + 0, 0, +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); +#else + -1, -1); +#endif return FALSE; } @@ -201,12 +227,14 @@ static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* even */ menu_shell = GTK_MENU_SHELL(selector); +#if !GTK_CHECK_VERSION (3, 0, 0) if (!menu_shell->active) { gtk_grab_add(GTK_WIDGET(menu_shell)); menu_shell->have_grab = TRUE; menu_shell->active = TRUE; } +#endif gtk_menu_shell_select_first(menu_shell, FALSE); return TRUE; @@ -261,7 +289,11 @@ gboolean window_menu_applet_fill(MatePanelApplet* applet) g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), window_menu); g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), window_menu); +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect_after(G_OBJECT(window_menu->selector), "draw", G_CALLBACK(window_menu_on_draw), window_menu); +#else g_signal_connect_after(G_OBJECT(window_menu->selector), "expose-event", G_CALLBACK(window_menu_on_expose), window_menu); +#endif g_signal_connect(G_OBJECT(window_menu->selector), "button_press_event", G_CALLBACK(filter_button_press), window_menu); diff --git a/applets/wncklet/wncklet.c b/applets/wncklet/wncklet.c index e7c37bbc..d17c2ee0 100644 --- a/applets/wncklet/wncklet.c +++ b/applets/wncklet/wncklet.c @@ -30,8 +30,8 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> -#include <libwnck/screen.h> -#include <libwnck/util.h> +#define WNCK_I_KNOW_THIS_IS_UNSTABLE +#include <libwnck/libwnck.h> #include "wncklet.h" #include "window-menu.h" diff --git a/applets/wncklet/wncklet.h b/applets/wncklet/wncklet.h index 4a5ff11a..a2230536 100644 --- a/applets/wncklet/wncklet.h +++ b/applets/wncklet/wncklet.h @@ -24,7 +24,7 @@ #ifndef __WNCKLET_H__ #define __WNCKLET_H__ -#include <libwnck/screen.h> +#include <libwnck/libwnck.h> #include <glib.h> #include <gtk/gtk.h> diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c index ad747516..29a386e4 100644 --- a/applets/wncklet/workspace-switcher.c +++ b/applets/wncklet/workspace-switcher.c @@ -21,9 +21,12 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> +#define WNCK_I_KNOW_THIS_IS_UNSTABLE #include <libwnck/libwnck.h> #include <gio/gio.h> +#include <libmate-desktop/mate-gsettings.h> + #include "workspace-switcher.h" #include "wncklet.h" @@ -192,7 +195,11 @@ static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient gtk_label_set_text(GTK_LABEL(pager->label_row_col), pager->orientation == GTK_ORIENTATION_HORIZONTAL ? _("rows") : _("columns")); } +#if GTK_CHECK_VERSION (3, 0, 0) +static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, PagerData* pager) +#else static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager) +#endif { /* taken from the TrashApplet */ GtkRcStyle *rc_style; @@ -204,6 +211,10 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac gtk_widget_modify_style (GTK_WIDGET (pager->pager), rc_style); g_object_unref (rc_style); +#if GTK_CHECK_VERSION (3, 0, 0) + wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), + type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN); +#else switch (type) { case PANEL_COLOR_BACKGROUND: @@ -223,6 +234,7 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac default: break; } +#endif } static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, PagerData* pager) @@ -517,7 +529,11 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet) break; } +#if WNCK_CHECK_VERSION (2, 91, 6) + pager->pager = wnck_pager_new(); +#else pager->pager = wnck_pager_new(NULL); +#endif pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; wnck_pager_set_shadow_type(WNCK_PAGER(pager->pager), GTK_SHADOW_IN); @@ -669,10 +685,12 @@ static void workspace_destroyed(WnckScreen* screen, WnckWorkspace* space, PagerD static void num_workspaces_value_changed(GtkSpinButton* button, PagerData* pager) { +#if !GTK_CHECK_VERSION (3, 0, 0) /* Slow down a bit after the first change, since it's moving really to * fast. See bug #336731 for background. * FIXME: remove this if bug 410520 gets fixed. */ button->timer_step = 0.2; +#endif wnck_screen_change_workspace_count(pager->screen, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin))); } @@ -747,6 +765,10 @@ static void close_dialog(GtkWidget* button, gpointer data) { PagerData* pager = data; GtkTreeViewColumn* col; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkCellArea *area; + GtkCellEditable *edit_widget; +#endif /* This is a hack. The "editable" signal for GtkCellRenderer is emitted only on button press or focus cycle. Hence when the user changes the @@ -757,8 +779,15 @@ static void close_dialog(GtkWidget* button, gpointer data) col = gtk_tree_view_get_column(GTK_TREE_VIEW(pager->workspaces_tree), 0); +#if GTK_CHECK_VERSION (3, 0, 0) + area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); + edit_widget = gtk_cell_area_get_edit_widget (area); + if (edit_widget) + gtk_cell_editable_editing_done (edit_widget); +#else if (col->editable_widget != NULL && GTK_IS_CELL_EDITABLE(col->editable_widget)) gtk_cell_editable_editing_done(col->editable_widget); +#endif gtk_widget_destroy(pager->properties_dialog); } @@ -770,7 +799,7 @@ setup_sensitivity(PagerData* pager, GtkBuilder* builder, const char* wid1, const { GtkWidget* w; - if (g_settings_is_writable(settings, key)) + if ((settings != NULL) && g_settings_is_writable(settings, key)) { return; } @@ -803,11 +832,13 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager) GtkTreeViewColumn* column; GtkCellRenderer* cell; int nr_ws, i; - GSettings *marco_general_settings; - GSettings *marco_workspaces_settings; + GSettings *marco_general_settings = NULL; + GSettings *marco_workspaces_settings = NULL; - marco_general_settings = g_settings_new (MARCO_GENERAL_SCHEMA); - marco_workspaces_settings = g_settings_new (MARCO_WORSKACES_SCHEMA); + if (mate_gsettings_schema_exists(MARCO_GENERAL_SCHEMA)) + marco_general_settings = g_settings_new (MARCO_GENERAL_SCHEMA); + if (mate_gsettings_schema_exists(MARCO_WORSKACES_SCHEMA)) + marco_workspaces_settings = g_settings_new (MARCO_WORSKACES_SCHEMA); pager->workspaces_frame = WID("workspaces_frame"); pager->workspace_names_label = WID("workspace_names_label"); @@ -833,8 +864,10 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager) pager->workspaces_tree = WID("workspaces_tree_view"); setup_sensitivity(pager, builder, "workspaces_tree_view", NULL, NULL, marco_workspaces_settings, WORKSPACE_NAME /* key */); - g_object_unref (marco_general_settings); - g_object_unref (marco_workspaces_settings); + if (marco_general_settings != NULL) + g_object_unref (marco_general_settings); + if (marco_workspaces_settings != NULL) + g_object_unref (marco_workspaces_settings); /* Wrap workspaces: */ |