summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor-xrender.c11
-rw-r--r--src/core/display.c21
-rw-r--r--src/core/errors.c11
-rw-r--r--src/core/keybindings.c1
-rw-r--r--src/core/main.c8
-rw-r--r--src/core/testasyncgetprop.c19
-rw-r--r--src/core/window.c22
-rw-r--r--src/tools/marco-mag.c4
-rw-r--r--src/tools/marco-window-demo.c452
-rw-r--r--src/ui/draw-workspace.c60
-rw-r--r--src/ui/fixedtip.c2
-rw-r--r--src/ui/fixedtip.h3
-rw-r--r--src/ui/frames.c49
-rw-r--r--src/ui/gradient.c174
-rw-r--r--src/ui/gradient.h20
-rw-r--r--src/ui/menu.c15
-rw-r--r--src/ui/preview-widget.c120
-rw-r--r--src/ui/resizepopup.c2
-rw-r--r--src/ui/tabpopup.c60
-rw-r--r--src/ui/testgradient.c117
-rw-r--r--src/ui/theme-parser.c12
-rw-r--r--src/ui/theme.c511
-rw-r--r--src/ui/theme.h74
-rw-r--r--src/ui/tile-preview.c74
-rw-r--r--src/ui/ui.c8
-rw-r--r--src/wm-tester/main.c30
26 files changed, 1402 insertions, 478 deletions
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index 68898257..31b0be2c 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -62,12 +62,6 @@
#define USE_IDLE_REPAINT 1
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
#ifdef HAVE_COMPOSITE_EXTENSIONS
static inline gboolean
composite_at_least_version (MetaDisplay *display,
@@ -1150,8 +1144,7 @@ paint_windows (MetaScreen *screen,
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
Display *xdisplay = meta_display_get_xdisplay (display);
GList *index, *last;
- int screen_width, screen_height, UNUSED_VARIABLE screen_number;
- Window UNUSED_VARIABLE xroot;
+ int screen_width, screen_height;
MetaCompWindow *cw;
XserverRegion paint_region, desktop_region;
@@ -1161,8 +1154,6 @@ paint_windows (MetaScreen *screen,
}
meta_screen_get_size (screen, &screen_width, &screen_height);
- screen_number = meta_screen_get_screen_number (screen);
- xroot = meta_screen_get_xroot (screen);
if (region == None)
{
diff --git a/src/core/display.c b/src/core/display.c
index 8a81d8f4..6a4831fb 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1482,6 +1482,15 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
return FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (gdk_display_device_is_grabbed(gdk_display, device))
+#else
+ if (gdk_display_pointer_is_grabbed(gdk_display))
+#endif
+ {
+ return FALSE;
+ }
+
switch (xevent->type)
{
@@ -2843,9 +2852,15 @@ key_event_description (Display *xdisplay,
XEvent *event)
{
#ifdef HAVE_XKB
- KeySym keysym = XkbKeycodeToKeysym(xdisplay, event->xkey.keycode, 0, 0);
- const char *str = XKeysymToString (keysym);
- return g_strdup_printf ("Key '%s' state 0x%x", str ? str : "none", event->xkey.state);
+ KeySym keysym;
+ const char *str;
+
+ keysym = XkbKeycodeToKeysym (xdisplay, event->xkey.keycode, 0, 0);
+
+ str = XKeysymToString (keysym);
+
+ return g_strdup_printf ("Key '%s' state 0x%x",
+ str ? str : "none", event->xkey.state);
#else
return "none";
#endif
diff --git a/src/core/errors.c b/src/core/errors.c
index 0dd43dc0..c2cf82d0 100644
--- a/src/core/errors.c
+++ b/src/core/errors.c
@@ -30,12 +30,6 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
#if !GTK_CHECK_VERSION (3, 0, 0)
static int x_error_handler (Display *display,
XErrorEvent *error);
@@ -162,10 +156,7 @@ meta_error_trap_pop_internal (MetaDisplay *display,
* assumes that there are no pending GDK traps from GDK itself
*/
- int UNUSED_VARIABLE (* restored_error_handler) (Display *,
- XErrorEvent *);
-
- restored_error_handler = XSetErrorHandler (x_error_handler);
+ XSetErrorHandler (x_error_handler);
/* remove this */
display->error_trap_handler = NULL;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 81b1c47f..9e809b68 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1311,6 +1311,7 @@ meta_display_process_key_event (MetaDisplay *display,
#ifdef HAVE_XKB
keysym = XkbKeycodeToKeysym (display->xdisplay, event->xkey.keycode, 0, 0);
+
str = XKeysymToString (keysym);
#else
str = NULL;
diff --git a/src/core/main.c b/src/core/main.c
index 66a5cdfb..d6d789e2 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -69,12 +69,6 @@
#include <time.h>
#include <unistd.h>
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
/**
* The exit code we'll return to our parent process when we eventually die.
*/
@@ -382,7 +376,7 @@ sigterm_handler (int signum)
{
if (sigterm_pipe_fds[1] >= 0)
{
- int UNUSED_VARIABLE dummy;
+ G_GNUC_UNUSED int dummy;
dummy = write (sigterm_pipe_fds[1], "", 1);
close (sigterm_pipe_fds[1]);
diff --git a/src/core/testasyncgetprop.c b/src/core/testasyncgetprop.c
index 826d7f41..d357dbea 100644
--- a/src/core/testasyncgetprop.c
+++ b/src/core/testasyncgetprop.c
@@ -81,12 +81,6 @@ print_backtrace (void)
}
#endif
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
static int error_trap_depth = 0;
static int
@@ -422,7 +416,6 @@ run_speed_comparison (Display *xdisplay,
while ((task = ag_get_next_completed_task (xdisplay)))
{
- int UNUSED_VARIABLE result;
Atom actual_type;
int actual_format;
unsigned long n_items;
@@ -432,12 +425,12 @@ run_speed_comparison (Display *xdisplay,
assert (ag_task_have_reply (task));
data = NULL;
- result = ag_task_get_reply_and_free (task,
- &actual_type,
- &actual_format,
- &n_items,
- &bytes_after,
- &data);
+ ag_task_get_reply_and_free (task,
+ &actual_type,
+ &actual_format,
+ &n_items,
+ &bytes_after,
+ &data);
if (data)
XFree (data);
diff --git a/src/core/window.c b/src/core/window.c
index d34845e8..95d49885 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -54,12 +54,6 @@
#include <X11/extensions/shape.h>
#endif
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
static int destroying_windows_disallowed = 0;
@@ -5348,12 +5342,11 @@ meta_window_client_message (MetaWindow *window,
else if (event->xclient.message_type ==
display->atom__NET_MOVERESIZE_WINDOW)
{
- int gravity, UNUSED_VARIABLE source;
+ int gravity;
guint value_mask;
gravity = (event->xclient.data.l[0] & 0xff);
value_mask = (event->xclient.data.l[0] & 0xf00) >> 8;
- source = (event->xclient.data.l[0] & 0xf000) >> 12;
if (gravity == 0)
gravity = window->size_hints.win_gravity;
@@ -5396,7 +5389,6 @@ meta_window_client_message (MetaWindow *window,
else if (event->xclient.message_type ==
display->atom__NET_WM_FULLSCREEN_MONITORS)
{
- MetaClientType UNUSED_VARIABLE source_indication;
gulong top, bottom, left, right;
meta_verbose ("_NET_WM_FULLSCREEN_MONITORS request for window '%s'\n",
@@ -5406,7 +5398,7 @@ meta_window_client_message (MetaWindow *window,
bottom = event->xclient.data.l[1];
left = event->xclient.data.l[2];
right = event->xclient.data.l[3];
- source_indication = event->xclient.data.l[4];
+ /* source_indication = event->xclient.data.l[4]; */
meta_window_update_fullscreen_monitors (window, top, bottom, left, right);
}
@@ -5607,8 +5599,6 @@ static gboolean
process_property_notify (MetaWindow *window,
XPropertyEvent *event)
{
- Window UNUSED_VARIABLE xid = window->xwindow;
-
if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
{
char *property_name = XGetAtomName (window->display->xdisplay,
@@ -5619,12 +5609,6 @@ process_property_notify (MetaWindow *window,
XFree (property_name);
}
- if (event->atom == window->display->atom__NET_WM_USER_TIME &&
- window->user_time_window)
- {
- xid = window->user_time_window;
- }
-
meta_window_reload_property (window, event->atom, FALSE);
return TRUE;
@@ -6849,7 +6833,6 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
{
MetaRectangle titlebar_rect;
GList *onscreen_region;
- int UNUSED_VARIABLE titlebar_size;
gboolean is_onscreen;
const int min_height_needed = 8;
@@ -6863,7 +6846,6 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
/* Get the rectangle corresponding to the titlebar */
meta_window_get_outer_rect (window, &titlebar_rect);
titlebar_rect.height = window->frame->child_y;
- titlebar_size = meta_rectangle_area (&titlebar_rect);
/* Run through the spanning rectangles for the screen and see if one of
* them overlaps with the titlebar sufficiently to consider it onscreen.
diff --git a/src/tools/marco-mag.c b/src/tools/marco-mag.c
index a87c9e3a..4b9f16c3 100644
--- a/src/tools/marco-mag.c
+++ b/src/tools/marco-mag.c
@@ -163,8 +163,8 @@ shutdown_grab (void)
#else
gdk_keyboard_ungrab (gtk_get_current_event_time ());
gdk_pointer_ungrab (gtk_get_current_event_time ());
- gtk_grab_remove (grab_widget);
#endif
+ gtk_grab_remove (grab_widget);
}
static void
@@ -245,6 +245,7 @@ begin_area_grab (void)
GdkDeviceManager *manager;
GdkDevice *device;
#endif
+
if (grab_widget == NULL)
{
grab_widget = gtk_invisible_new ();
@@ -267,7 +268,6 @@ begin_area_grab (void)
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
NULL,
gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
-
{
g_warning ("Failed to grab pointer to do eyedropper");
return;
diff --git a/src/tools/marco-window-demo.c b/src/tools/marco-window-demo.c
index 8cfaf952..1585b385 100644
--- a/src/tools/marco-window-demo.c
+++ b/src/tools/marco-window-demo.c
@@ -29,7 +29,14 @@
#define gtk_hbox_new(X, Y) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, Y)
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+do_appwindow (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+#else
static GtkWidget* do_appwindow (void);
+#endif
static gboolean aspect_on;
@@ -223,7 +230,11 @@ main (int argc, char **argv)
g_error_free (err);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ do_appwindow (NULL, NULL, NULL);
+#else
do_appwindow ();
+#endif
gtk_main ();
@@ -289,18 +300,32 @@ response_cb (GtkDialog *dialog,
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+dialog_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
dialog_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
make_dialog (GTK_WIDGET (callback_data), 1);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+modal_dialog_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
modal_dialog_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *dialog;
@@ -317,18 +342,32 @@ modal_dialog_cb (gpointer callback_data,
gtk_widget_destroy (dialog);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+no_parent_dialog_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
no_parent_dialog_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
make_dialog (NULL, 1);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+utility_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
utility_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *vbox;
@@ -359,10 +398,17 @@ utility_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+toolbar_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
toolbar_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *vbox;
@@ -384,10 +430,17 @@ toolbar_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+menu_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
menu_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *vbox;
@@ -409,10 +462,17 @@ menu_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+override_redirect_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
override_redirect_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *vbox;
@@ -431,10 +491,17 @@ override_redirect_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+border_only_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
border_only_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *vbox;
@@ -501,10 +568,17 @@ focus_label (GtkWidget *window)
return label;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+splashscreen_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
splashscreen_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *image;
@@ -610,11 +684,37 @@ make_dock (int type)
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+dock_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
dock_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ guint callback_action;
+ const gchar *name;
+
+ g_object_get (G_OBJECT (action), "name", &name, NULL);
+
+ if (!g_strcmp0 (name, "top-dock"))
+ callback_action = DOCK_TOP;
+ else if (!g_strcmp0 (name, "bottom-dock"))
+ callback_action = DOCK_BOTTOM;
+ else if (!g_strcmp0 (name, "left-dock"))
+ callback_action = DOCK_LEFT;
+ else if (!g_strcmp0 (name, "right-dock"))
+ callback_action = DOCK_RIGHT;
+ else if (!g_strcmp0 (name, "all-docks"))
+ callback_action = DOCK_ALL;
+ else
+ return;
+#endif
if (callback_action == DOCK_ALL)
{
make_dock (DOCK_TOP);
@@ -628,33 +728,25 @@ dock_cb (gpointer callback_data,
}
}
-#if GTK_CHECK_VERSION(3, 0, 0)
-
-static void top_dock_cb()
- { make_dock(DOCK_TOP); }
-
-static void bottom_dock_cb()
- { make_dock(DOCK_BOTTOM); }
-
-static void left_dock_cb()
- { make_dock(DOCK_LEFT); }
-
-static void right_dock_cb()
- { make_dock(DOCK_RIGHT); }
-
-static void all_dock_cb()
- { dock_cb(NULL, DOCK_ALL, NULL); }
-
-#endif
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+desktop_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer callback_data)
+#else
static void
desktop_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
+#endif
{
GtkWidget *window;
GtkWidget *label;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA desktop_color;
+#else
GdkColor desktop_color;
+#endif
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DESKTOP");
@@ -663,11 +755,20 @@ desktop_cb (gpointer callback_data,
gdk_screen_width (), gdk_screen_height ());
gtk_window_move (GTK_WINDOW (window), 0, 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ desktop_color.red = 0.32;
+ desktop_color.green = 0.46;
+ desktop_color.blue = 0.65;
+ desktop_color.alpha = 1.0;
+
+ gtk_widget_override_background_color (window, 0, &desktop_color);
+#else
desktop_color.red = 0x5144;
desktop_color.green = 0x75D6;
desktop_color.blue = 0xA699;
gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &desktop_color);
+#endif
label = focus_label (window);
@@ -676,62 +777,7 @@ desktop_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
-#if GTK_CHECK_VERSION(3, 0, 0)
-
-static gchar ui_definition[] =
-"<ui>\
- <menubar name=\"MainMenuBar\">\
- <menu name=\"WindowsMenu\">\
- <menuitem name=\"Dialog\" action=\"DialogAction\" />\
- <menuitem name=\"ModalDialog\" action=\"ModalDialogAction\" />\
- <menuitem name=\"ParentlessDialog\" action=\"ParentlessDialogAction\" />\
- <menuitem name=\"Utility\" action=\"UtilityAction\" />\
- <menuitem name=\"Splashscreen\" action=\"SplashscreenAction\" />\
- <menuitem name=\"TopDock\" action=\"TopDockAction\" />\
- <menuitem name=\"BottomDock\" action=\"BottomDockAction\" />\
- <menuitem name=\"LeftDock\" action=\"LeftDockAction\" />\
- <menuitem name=\"RightDock\" action=\"RightDockAction\" />\
- <menuitem name=\"AllDocks\" action=\"AllDocksAction\" />\
- <menuitem name=\"Desktop\" action=\"DesktopAction\" />\
- <menuitem name=\"Menu\" action=\"MenuAction\" />\
- <menuitem name=\"Toolbar\" action=\"ToolbarAction\" />\
- <menuitem name=\"OverrideRedirect\" action=\"OverrideRedirectAction\" />\
- <menuitem name=\"BorderOnly\" action=\"BorderOnlyAction\" />\
- </menu>\
- </menubar>\
-</ui>";
-
-static GtkActionEntry entries[] =
-{
- /*
- struct GtkActionEntry {
- const gchar *name;
- const gchar *stock_id;
- const gchar *label;
- const gchar *accelerator;
- const gchar *tooltip;
- GCallback callback;
- }; */
-
- {"DialogAction" , NULL , "_Dialog" , "<control>d" , NULL , G_CALLBACK(dialog_cb)} ,
- {"ModalDialogAction" , NULL , "_Modal dialog" , NULL , NULL , G_CALLBACK(modal_dialog_cb)} ,
- {"ParentlessDialogAction" , NULL , "_Parentless dialog" , NULL , NULL , G_CALLBACK(no_parent_dialog_cb)} ,
- {"UtilityAction" , NULL , "_Utility" , "<control>u" , NULL , G_CALLBACK(utility_cb)} ,
- {"SplashscreenAction" , NULL , "_Splashscreen" , "<control>s" , NULL , G_CALLBACK(splashscreen_cb)} ,
- {"TopDockAction" , NULL , "_Top dock" , NULL , NULL , G_CALLBACK(top_dock_cb)} ,
- {"BottomDockAction" , NULL , "_Bottom dock" , NULL , NULL , G_CALLBACK(bottom_dock_cb)} ,
- {"LeftDockAction" , NULL , "_Left dock" , NULL , NULL , G_CALLBACK(left_dock_cb)} ,
- {"RightDockAction" , NULL , "_Right dock" , NULL , NULL , G_CALLBACK(right_dock_cb)} ,
- {"AllDocksAction" , NULL , "_All docks" , NULL , NULL , G_CALLBACK(all_dock_cb)} ,
- {"DesktopAction" , NULL , "Des_ktop" , NULL , NULL , G_CALLBACK(desktop_cb)} ,
- {"MenuAction" , NULL , "Me_nu" , NULL , NULL , G_CALLBACK(menu_cb)} ,
- {"ToolbarAction" , NULL , "Tool_bar" , NULL , NULL , G_CALLBACK(toolbar_cb)} ,
- {"OverrideRedirectAction" , NULL , "Override Redirect" , NULL , NULL , G_CALLBACK(override_redirect_cb)} ,
- {"BorderOnly" , NULL , "Border Only" , NULL , NULL , G_CALLBACK(border_only_cb)} ,
-};
-
-#else
-
+#if !GTK_CHECK_VERSION(3, 0, 0)
static GtkItemFactoryEntry menu_items[] =
{
{ "/_Windows", NULL, NULL, 0, "<Branch>" },
@@ -755,16 +801,30 @@ static GtkItemFactoryEntry menu_items[] =
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+sleep_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+#else
static void
sleep_cb (GtkWidget *button,
gpointer data)
+#endif
{
sleep (1000);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+toggle_aspect_ratio (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+#else
static void
toggle_aspect_ratio (GtkWidget *button,
gpointer data)
+#endif
{
GtkWidget *window;
GdkGeometry geom;
@@ -782,7 +842,11 @@ toggle_aspect_ratio (GtkWidget *button,
aspect_on = !aspect_on;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ window = gtk_widget_get_ancestor (GTK_WIDGET(data), GTK_TYPE_WINDOW);
+#else
window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
+#endif
if (window)
gtk_window_set_geometry_hints (GTK_WINDOW (window),
GTK_WIDGET (data),
@@ -791,20 +855,38 @@ toggle_aspect_ratio (GtkWidget *button,
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+toggle_decorated_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+#else
static void
toggle_decorated_cb (GtkWidget *button,
gpointer data)
+#endif
{
GtkWidget *window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window = gtk_widget_get_ancestor (data, GTK_TYPE_WINDOW);
+#else
window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
+#endif
if (window)
gtk_window_set_decorated (GTK_WINDOW (window),
!gtk_window_get_decorated (GTK_WINDOW (window)));
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+clicked_toolbar_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+#else
static void
clicked_toolbar_cb (GtkWidget *button,
gpointer data)
+#endif
{
GtkWidget *dialog;
@@ -870,21 +952,172 @@ destroy_cb (GtkWidget *w, gpointer data)
gtk_main_quit ();
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static const gchar *xml =
+ "<interface>"
+ "<menu id='menubar'>"
+ "<submenu>"
+ "<attribute name='label'>Windows</attribute>"
+ "<section>"
+ "<item>"
+ "<attribute name='label'>Dialog</attribute>"
+ "<attribute name='action'>demo.dialog1</attribute>"
+ "<attribute name='accel'>&lt;control&gt;d</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Modal dialog</attribute>"
+ "<attribute name='action'>demo.dialog2</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Parentless dialog</attribute>"
+ "<attribute name='action'>demo.dialog3</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Utility</attribute>"
+ "<attribute name='action'>demo.utility</attribute>"
+ "<attribute name='accel'>&lt;control&gt;u</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Splashscreen</attribute>"
+ "<attribute name='action'>demo.splashscreen</attribute>"
+ "<attribute name='accel'>&lt;control&gt;s</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Top dock</attribute>"
+ "<attribute name='action'>demo.top-dock</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Bottom dock</attribute>"
+ "<attribute name='action'>demo.bottom-dock</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Left dock</attribute>"
+ "<attribute name='action'>demo.left-dock</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Right dock</attribute>"
+ "<attribute name='action'>demo.right-dock</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>All docks</attribute>"
+ "<attribute name='action'>demo.all-docks</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Desktop</attribute>"
+ "<attribute name='action'>demo.desktop</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Menu</attribute>"
+ "<attribute name='action'>demo.menu</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Toolbar</attribute>"
+ "<attribute name='action'>demo.toolbar</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Override Redirect</attribute>"
+ "<attribute name='action'>demo.override-redirect</attribute>"
+ "</item>"
+ "<item>"
+ "<attribute name='label'>Border Only</attribute>"
+ "<attribute name='action'>demo.border-only</attribute>"
+ "</item>"
+ "</section>"
+ "</submenu>"
+ "</menu>"
+ "</interface>";
+
+static GActionEntry demo_entries[] =
+{
+ /* menubar */
+ { "dialog1", dialog_cb, NULL, NULL, NULL, {} },
+ { "dialog2", modal_dialog_cb, NULL, NULL, NULL, {} },
+ { "dialog3", no_parent_dialog_cb, NULL, NULL, NULL, {} },
+ { "utility", utility_cb, NULL, NULL, NULL, {} },
+ { "splashscreen", splashscreen_cb, NULL, NULL, NULL, {} },
+ { "top-dock", dock_cb, NULL, NULL, NULL, {} },
+ { "bottom-dock", dock_cb, NULL, NULL, NULL, {} },
+ { "left-dock", dock_cb, NULL, NULL, NULL, {} },
+ { "right-dock", dock_cb, NULL, NULL, NULL, {} },
+ { "all-docks", dock_cb, NULL, NULL, NULL, {} },
+ { "desktop", desktop_cb, NULL, NULL, NULL, {} },
+ { "menu", menu_cb, NULL, NULL, NULL, {} },
+ { "toolbar", toolbar_cb, NULL, NULL, NULL, {} },
+ { "override-redirect", override_redirect_cb, NULL, NULL, NULL, {} },
+ { "border-only", border_only_cb, NULL, NULL, NULL, {} },
+ /* toolbar */
+ { "new", do_appwindow, NULL, NULL, NULL, {} },
+ { "lock", sleep_cb, NULL, NULL, NULL, {} },
+ { "decorations", toggle_decorated_cb, NULL, NULL, NULL, {} },
+ { "quit", clicked_toolbar_cb, NULL, NULL, NULL, {} },
+ { "ratio", toggle_aspect_ratio, NULL, NULL, NULL, {} },
+};
+
+static GtkWidget *
+create_toolbar (void)
+{
+ GtkWidget *toolbar;
+ GtkToolItem *item;
+
+ toolbar = gtk_toolbar_new ();
+
+ item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-new", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
+ gtk_tool_item_set_tooltip_markup (item, "Open another one of these windows");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.new");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
+ gtk_tool_item_set_tooltip_markup (item, "This is a demo button that locks up the demo");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.lock");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
+ gtk_tool_item_set_tooltip_markup (item, "This is a demo button that toggles window decorations");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.decorations");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
+ gtk_tool_item_set_tooltip_markup (item, "This is a demo button that locks the aspect ratio using a hint");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.ratio");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new (gtk_image_new_from_icon_name ("gtk-quit", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
+ gtk_tool_item_set_tooltip_markup (item, "This is a demo button with a 'quit' icon");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.quit");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ return toolbar;
+}
+#endif
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+do_appwindow (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+#else
static GtkWidget *
do_appwindow (void)
+#endif
{
GtkWidget *window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkWidget *grid;
+#else
GtkWidget *table;
+#endif
GtkWidget *toolbar;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *handlebox;
+#endif
GtkWidget *statusbar;
GtkWidget *contents;
GtkWidget *sw;
GtkTextBuffer *buffer;
#if GTK_CHECK_VERSION(3, 0, 0)
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
+ GSimpleActionGroup *action_group;
+ GtkBuilder *builder;
#else
GtkAccelGroup *accel_group;
GtkItemFactory *item_factory;
@@ -904,29 +1137,44 @@ do_appwindow (void)
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (destroy_cb), NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ grid = gtk_grid_new ();
+
+ gtk_widget_set_vexpand (grid, TRUE);
+ gtk_widget_set_hexpand (grid, TRUE);
+
+ gtk_container_add (GTK_CONTAINER (window), grid);
+#else
table = gtk_table_new (1, 4, FALSE);
gtk_container_add (GTK_CONTAINER (window), table);
+#endif
- #if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ action_group = g_simple_action_group_new ();
+ builder = gtk_builder_new_from_string (xml, -1);
- action_group = gtk_action_group_new("ActionGroups");
- gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), NULL);
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ demo_entries,
+ G_N_ELEMENTS (demo_entries),
+ window);
+ gtk_widget_insert_action_group (window, "demo", G_ACTION_GROUP (action_group));
- ui_manager = gtk_ui_manager_new();
- gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
- gtk_ui_manager_add_ui_from_string(ui_manager, ui_definition, -1, NULL);
+ /* Create the menubar
+ */
- gtk_table_attach (GTK_TABLE (table),
- gtk_ui_manager_get_widget (ui_manager, "/MainMenuBar"),
- /* X direction */ /* Y direction */
- 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL, 0,
- 0, 0);
+ GMenuModel *model = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
+ GtkWidget *menubar = gtk_menu_bar_new_from_model (model);
+ gtk_grid_attach (GTK_GRID (grid), menubar, 0, 0, 1, 1);
+ gtk_widget_set_hexpand (menubar, TRUE);
- gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui_manager));
+ /* Create the toolbar
+ */
- #else
+ toolbar = create_toolbar ();
+ gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 1, 1, 1);
+ gtk_widget_set_hexpand (toolbar, TRUE);
+#else
/* Create the menubar
*/
@@ -958,7 +1206,7 @@ do_appwindow (void)
0, 0);
- #endif
+#endif
/* Create document
*/
@@ -972,12 +1220,19 @@ do_appwindow (void)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_IN);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_grid_attach (GTK_GRID (grid), sw, 0, 2, 1, 1);
+
+ gtk_widget_set_hexpand (sw, TRUE);
+ gtk_widget_set_vexpand (sw, TRUE);
+#else
gtk_table_attach (GTK_TABLE (table),
sw,
/* X direction */ /* Y direction */
0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
0, 0);
+#endif
gtk_window_set_default_size (GTK_WINDOW (window),
200, 200);
@@ -989,6 +1244,7 @@ do_appwindow (void)
gtk_container_add (GTK_CONTAINER (sw),
contents);
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Create the toolbar
*/
toolbar = gtk_toolbar_new ();
@@ -1060,16 +1316,21 @@ do_appwindow (void)
0, 1, 1, 2,
GTK_EXPAND | GTK_FILL, 0,
0, 0);
-
+#endif
/* Create statusbar */
statusbar = gtk_statusbar_new ();
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_grid_attach (GTK_GRID (grid), statusbar, 0, 3, 1, 1);
+ gtk_widget_set_hexpand (statusbar, TRUE);
+#else
gtk_table_attach (GTK_TABLE (table),
statusbar,
/* X direction */ /* Y direction */
0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, 0,
0, 0);
+#endif
/* Show text widget info in the statusbar */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
@@ -1097,7 +1358,12 @@ do_appwindow (void)
gtk_widget_show_all (window);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_object_unref (action_group);
+ g_object_unref (builder);
+#else
return window;
+#endif
}
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index 1831b46c..a40579db 100644
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
@@ -27,6 +27,11 @@
#include "draw-workspace.h"
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h>
+#endif
+
static void
get_window_rect (const WnckWindowDisplayInfo *win,
@@ -83,13 +88,18 @@ draw_window (GtkWidget *widget,
GdkPixbuf *icon;
int icon_x, icon_y, icon_w, icon_h;
gboolean is_active;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+ GtkStyleContext *style;
+#else
GdkColor *color;
GtkStyle *style;
+#endif
is_active = win->is_active;
#if GTK_CHECK_VERSION(3, 0, 0)
- cairo_save(cr);
+ cairo_save (cr);
#else
cr = gdk_cairo_create (drawable);
#endif
@@ -97,6 +107,14 @@ draw_window (GtkWidget *widget,
cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
cairo_clip (cr);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ style = gtk_widget_get_style_context (widget);
+ if (is_active)
+ mate_desktop_gtk_style_get_light_color (style, state, &color);
+ else
+ gtk_style_context_get_background_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
style = gtk_widget_get_style (widget);
if (is_active)
color = &style->light[state];
@@ -106,6 +124,7 @@ draw_window (GtkWidget *widget,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
+#endif
cairo_rectangle (cr,
winrect->x + 1, winrect->y + 1,
@@ -156,15 +175,17 @@ draw_window (GtkWidget *widget,
cairo_restore (cr);
}
- if (is_active)
- color = &style->fg[state];
- else
- color = &style->fg[state];
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_style_context_get_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
+ color = &style->fg[state];
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
winrect->x + 0.5, winrect->y + 0.5,
@@ -198,10 +219,13 @@ wnck_draw_workspace (GtkWidget *widget,
{
int i;
GdkRectangle workspace_rect;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStateFlags state;
+ GtkStyleContext *style;
+#else
GtkStateType state;
- #if !GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr;
- #endif
+#endif
workspace_rect.x = x;
workspace_rect.y = y;
@@ -209,14 +233,27 @@ wnck_draw_workspace (GtkWidget *widget,
workspace_rect.height = height;
if (is_active)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ state = GTK_STATE_FLAG_SELECTED;
+#else
state = GTK_STATE_SELECTED;
+#endif
else if (workspace_background)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ state = GTK_STATE_FLAG_PRELIGHT;
+#else
state = GTK_STATE_PRELIGHT;
+#endif
else
+#if GTK_CHECK_VERSION (3, 0, 0)
+ state = GTK_STATE_FLAG_NORMAL;
+#else
state = GTK_STATE_NORMAL;
+#endif
#if GTK_CHECK_VERSION(3, 0, 0)
- cairo_save(cr);
+ style = gtk_widget_get_style_context (widget);
+ cairo_save (cr);
#else
cr = gdk_cairo_create (drawable);
#endif
@@ -228,7 +265,14 @@ wnck_draw_workspace (GtkWidget *widget,
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+
+ mate_desktop_gtk_style_get_dark_color (style,state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->dark[state]);
+#endif
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
}
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index 6f07c6bb..fc1be2af 100644
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
@@ -84,7 +84,7 @@ expose_handler (GtkTooltips *tooltips)
#endif
void
-meta_fixed_tip_show (Display *xdisplay, int screen_number,
+meta_fixed_tip_show (int screen_number,
int root_x, int root_y,
const char *markup_text)
{
diff --git a/src/ui/fixedtip.h b/src/ui/fixedtip.h
index e3eac8f5..f20f0d2c 100644
--- a/src/ui/fixedtip.h
+++ b/src/ui/fixedtip.h
@@ -49,13 +49,12 @@
* displayed, but if it is the window will be reused rather than destroyed
* and recreated.
*
- * \param xdisplay An X display.
* \param screen_number The number of the screen.
* \param root_x The X coordinate where the tooltip should appear
* \param root_y The Y coordinate where the tooltip should appear
* \param markup_text Text to display in the tooltip; can contain markup
*/
-void meta_fixed_tip_show (Display *xdisplay, int screen_number,
+void meta_fixed_tip_show (int screen_number,
int root_x, int root_y,
const char *markup_text);
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 60e09ea3..099c5052 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1099,16 +1099,14 @@ meta_frames_move_resize_frame (MetaFrames *frames,
int height)
{
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
- int old_x, old_y, old_width, old_height;
+ int old_width, old_height;
- #if GTK_CHECK_VERSION(3, 0, 0)
- old_width = gdk_window_get_width(GDK_WINDOW(frame->window));
- old_height = gdk_window_get_height(GDK_WINDOW(frame->window));
- #else
- gdk_drawable_get_size(frame->window, &old_width, &old_height);
- #endif
-
- gdk_window_get_position (frame->window, &old_x, &old_y);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ old_width = gdk_window_get_width (frame->window);
+ old_height = gdk_window_get_height (frame->window);
+#else
+ gdk_drawable_get_size(frame->window, &old_width, &old_height);
+#endif
gdk_window_move_resize (frame->window, x, y, width, height);
@@ -1270,8 +1268,7 @@ show_tip_now (MetaFrames *frames)
screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames)));
- meta_fixed_tip_show (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- screen_number,
+ meta_fixed_tip_show (screen_number,
rect->x + dx,
rect->y + rect->height + 2 + dy,
tiptext);
@@ -2580,7 +2577,6 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
int y_offset)
#endif
{
- GtkWidget *widget;
MetaFrameFlags flags;
MetaFrameType type;
GdkPixbuf *mini_icon;
@@ -2592,8 +2588,6 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
MetaButtonLayout button_layout;
MetaGrabOp grab_op;
- widget = GTK_WIDGET (frames);
-
for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
button_states[i] = META_BUTTON_STATE_NORMAL;
@@ -2694,7 +2688,6 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
meta_theme_draw_frame_with_style (meta_theme_get_current (),
frame->style,
- widget,
cr,
type,
flags,
@@ -2767,8 +2760,11 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
gdk_window_begin_paint_rect (drawable, &areas[i]);
meta_theme_draw_frame_with_style (meta_theme_get_current (),
+#if GTK_CHECK_VERSION (3, 0, 0)
frame->style,
- widget,
+#else
+ GTK_WIDGET(frames),
+#endif
drawable,
NULL, /* &areas[i], */
x_offset, y_offset,
@@ -2793,8 +2789,11 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
/* Not a window; happens about 1/3 of the time */
meta_theme_draw_frame_with_style (meta_theme_get_current (),
+#if GTK_CHECK_VERSION (3, 0, 0)
frame->style,
- widget,
+#else
+ GTK_WIDGET(frames),
+#endif
drawable,
NULL,
x_offset, y_offset,
@@ -2835,23 +2834,35 @@ meta_frames_set_window_background (MetaFrames *frames,
if (frame_exists && style->window_background_color != NULL)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
GdkVisual *visual;
meta_color_spec_render (style->window_background_color,
- GTK_WIDGET (frames),
+ frame->style,
&color);
/* Set A in ARGB to window_background_alpha, if we have ARGB */
visual = gtk_widget_get_visual (GTK_WIDGET (frames));
- if (gdk_visual_get_depth(visual) == 32) /* we have ARGB */
+ if (gdk_visual_get_depth (visual) == 32) /* we have ARGB */
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ {
+ color.alpha = style->window_background_alpha / 255.0;
+ }
+
+ gdk_window_set_background_rgba (frame->window, &color);
+ #else
{
color.pixel = (color.pixel & 0xffffff) &
style->window_background_alpha << 24;
}
gdk_window_set_background (frame->window, &color);
+ #endif
}
else
{
diff --git a/src/ui/gradient.c b/src/ui/gradient.c
index 78a5a9eb..dfdb2fa1 100644
--- a/src/ui/gradient.c
+++ b/src/ui/gradient.c
@@ -26,9 +26,37 @@
#include "util.h"
#include <string.h>
+#include <gtk/gtk.h>
+
/* This is all Alfredo's and Dan's usual very nice WindowMaker code,
* slightly GTK-ized
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf* meta_gradient_create_horizontal (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to);
+static GdkPixbuf* meta_gradient_create_vertical (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to);
+static GdkPixbuf* meta_gradient_create_diagonal (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to);
+static GdkPixbuf* meta_gradient_create_multi_horizontal (int width,
+ int height,
+ const GdkRGBA *colors,
+ int count);
+static GdkPixbuf* meta_gradient_create_multi_vertical (int width,
+ int height,
+ const GdkRGBA *colors,
+ int count);
+static GdkPixbuf* meta_gradient_create_multi_diagonal (int width,
+ int height,
+ const GdkRGBA *colors,
+ int count);
+#else
static GdkPixbuf* meta_gradient_create_horizontal (int width,
int height,
const GdkColor *from,
@@ -53,6 +81,7 @@ static GdkPixbuf* meta_gradient_create_multi_diagonal (int width,
int height,
const GdkColor *colors,
int count);
+#endif
/* Used as the destroy notification function for gdk_pixbuf_new() */
@@ -87,12 +116,21 @@ blank_pixbuf (int width, int height, gboolean no_padding)
free_buffer, NULL);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf*
+meta_gradient_create_simple (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to,
+ MetaGradientType style)
+#else
GdkPixbuf*
meta_gradient_create_simple (int width,
int height,
const GdkColor *from,
const GdkColor *to,
MetaGradientType style)
+#endif
{
switch (style)
{
@@ -113,12 +151,21 @@ meta_gradient_create_simple (int width,
return NULL;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf*
+meta_gradient_create_multi (int width,
+ int height,
+ const GdkRGBA *colors,
+ int n_colors,
+ MetaGradientType style)
+#else
GdkPixbuf*
meta_gradient_create_multi (int width,
int height,
const GdkColor *colors,
int n_colors,
MetaGradientType style)
+#endif
{
if (n_colors > 2)
@@ -155,6 +202,15 @@ meta_gradient_create_multi (int width,
* are alternated. I'm not sure what it's good for, just copied since
* WindowMaker had it.
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf*
+meta_gradient_create_interwoven (int width,
+ int height,
+ const GdkRGBA colors1[2],
+ int thickness1,
+ const GdkRGBA colors2[2],
+ int thickness2)
+#else
GdkPixbuf*
meta_gradient_create_interwoven (int width,
int height,
@@ -162,6 +218,7 @@ meta_gradient_create_interwoven (int width,
int thickness1,
const GdkColor colors2[2],
int thickness2)
+#endif
{
int i, j, k, l, ll;
@@ -179,6 +236,23 @@ meta_gradient_create_interwoven (int width,
pixels = gdk_pixbuf_get_pixels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r1 = (long)(colors1[0].red*0xffffff);
+ g1 = (long)(colors1[0].green*0xffffff);
+ b1 = (long)(colors1[0].blue*0xffffff);
+
+ r2 = (long)(colors2[0].red*0xffffff);
+ g2 = (long)(colors2[0].green*0xffffff);
+ b2 = (long)(colors2[0].blue*0xffffff);
+
+ dr1 = ((colors1[1].red-colors1[0].red)*0xffffff)/(int)height;
+ dg1 = ((colors1[1].green-colors1[0].green)*0xffffff)/(int)height;
+ db1 = ((colors1[1].blue-colors1[0].blue)*0xffffff)/(int)height;
+
+ dr2 = ((colors2[1].red-colors2[0].red)*0xffffff)/(int)height;
+ dg2 = ((colors2[1].green-colors2[0].green)*0xffffff)/(int)height;
+ db2 = ((colors2[1].blue-colors2[0].blue)*0xffffff)/(int)height;
+#else
r1 = colors1[0].red<<8;
g1 = colors1[0].green<<8;
b1 = colors1[0].blue<<8;
@@ -194,6 +268,7 @@ meta_gradient_create_interwoven (int width,
dr2 = ((colors2[1].red-colors2[0].red)<<8)/(int)height;
dg2 = ((colors2[1].green-colors2[0].green)<<8)/(int)height;
db2 = ((colors2[1].blue-colors2[0].blue)<<8)/(int)height;
+#endif
for (i=0,k=0,l=0,ll=thickness1; i<height; i++)
{
@@ -255,10 +330,17 @@ meta_gradient_create_interwoven (int width,
* None
*----------------------------------------------------------------------
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_horizontal (int width, int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to)
+#else
static GdkPixbuf*
meta_gradient_create_horizontal (int width, int height,
const GdkColor *from,
const GdkColor *to)
+#endif
{
int i;
long r, g, b, dr, dg, db;
@@ -277,12 +359,21 @@ meta_gradient_create_horizontal (int width, int height,
ptr = pixels;
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r0 = (guchar) (from->red * 0xff);
+ g0 = (guchar) (from->green * 0xff);
+ b0 = (guchar) (from->blue * 0xff);
+ rf = (guchar) (to->red * 0xff);
+ gf = (guchar) (to->green * 0xff);
+ bf = (guchar) (to->blue * 0xff);
+#else
r0 = (guchar) (from->red / 256.0);
g0 = (guchar) (from->green / 256.0);
b0 = (guchar) (from->blue / 256.0);
rf = (guchar) (to->red / 256.0);
gf = (guchar) (to->green / 256.0);
bf = (guchar) (to->blue / 256.0);
+#endif
r = r0 << 16;
g = g0 << 16;
@@ -323,10 +414,17 @@ meta_gradient_create_horizontal (int width, int height,
* None
*----------------------------------------------------------------------
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_vertical (int width, int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to)
+#else
static GdkPixbuf*
meta_gradient_create_vertical (int width, int height,
const GdkColor *from,
const GdkColor *to)
+#endif
{
int i, j;
long r, g, b, dr, dg, db;
@@ -344,12 +442,21 @@ meta_gradient_create_vertical (int width, int height,
pixels = gdk_pixbuf_get_pixels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r0 = (guchar) (from->red * 0xff);
+ g0 = (guchar) (from->green * 0xff);
+ b0 = (guchar) (from->blue * 0xff);
+ rf = (guchar) (to->red * 0xff);
+ gf = (guchar) (to->green * 0xff);
+ bf = (guchar) (to->blue * 0xff);
+#else
r0 = (guchar) (from->red / 256.0);
g0 = (guchar) (from->green / 256.0);
b0 = (guchar) (from->blue / 256.0);
rf = (guchar) (to->red / 256.0);
gf = (guchar) (to->green / 256.0);
bf = (guchar) (to->blue / 256.0);
+#endif
r = r0<<16;
g = g0<<16;
@@ -393,11 +500,17 @@ meta_gradient_create_vertical (int width, int height,
*----------------------------------------------------------------------
*/
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_diagonal (int width, int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to)
+#else
static GdkPixbuf*
meta_gradient_create_diagonal (int width, int height,
const GdkColor *from,
const GdkColor *to)
+#endif
{
GdkPixbuf *pixbuf, *tmp;
int j;
@@ -441,11 +554,17 @@ meta_gradient_create_diagonal (int width, int height,
return pixbuf;
}
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_multi_horizontal (int width, int height,
+ const GdkRGBA *colors,
+ int count)
+#else
static GdkPixbuf*
meta_gradient_create_multi_horizontal (int width, int height,
const GdkColor *colors,
int count)
+#endif
{
int i, j, k;
long r, g, b, dr, dg, db;
@@ -475,16 +594,28 @@ meta_gradient_create_multi_horizontal (int width, int height,
k = 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r = (long)(colors[0].red * 0xffffff);
+ g = (long)(colors[0].green * 0xffffff);
+ b = (long)(colors[0].blue * 0xffffff);
+#else
r = colors[0].red << 8;
g = colors[0].green << 8;
b = colors[0].blue << 8;
+#endif
/* render the first line */
for (i=1; i<count; i++)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ dr = (int)((colors[i].red - colors[i-1].red) *0xffffff)/(int)width2;
+ dg = (int)((colors[i].green - colors[i-1].green)*0xffffff)/(int)width2;
+ db = (int)((colors[i].blue - colors[i-1].blue) *0xffffff)/(int)width2;
+#else
dr = ((int)(colors[i].red - colors[i-1].red) <<8)/(int)width2;
dg = ((int)(colors[i].green - colors[i-1].green)<<8)/(int)width2;
db = ((int)(colors[i].blue - colors[i-1].blue) <<8)/(int)width2;
+#endif
for (j=0; j<width2; j++)
{
*ptr++ = (unsigned char)(r>>16);
@@ -495,9 +626,15 @@ meta_gradient_create_multi_horizontal (int width, int height,
b += db;
k++;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r = (long)(colors[i].red * 0xffffff);
+ g = (long)(colors[i].green * 0xffffff);
+ b = (long)(colors[i].blue * 0xffffff);
+#else
r = colors[i].red << 8;
g = colors[i].green << 8;
b = colors[i].blue << 8;
+#endif
}
for (j=k; j<width; j++)
{
@@ -514,10 +651,17 @@ meta_gradient_create_multi_horizontal (int width, int height,
return pixbuf;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_multi_vertical (int width, int height,
+ const GdkRGBA *colors,
+ int count)
+#else
static GdkPixbuf*
meta_gradient_create_multi_vertical (int width, int height,
const GdkColor *colors,
int count)
+#endif
{
int i, j, k;
long r, g, b, dr, dg, db;
@@ -547,15 +691,27 @@ meta_gradient_create_multi_vertical (int width, int height,
k = 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r = (long)(colors[0].red * 0xffffff);
+ g = (long)(colors[0].green * 0xffffff);
+ b = (long)(colors[0].blue * 0xffffff);
+#else
r = colors[0].red << 8;
g = colors[0].green << 8;
b = colors[0].blue << 8;
+#endif
for (i=1; i<count; i++)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ dr = (int)((colors[i].red - colors[i-1].red) *0xffffff)/(int)height2;
+ dg = (int)((colors[i].green - colors[i-1].green)*0xffffff)/(int)height2;
+ db = (int)((colors[i].blue - colors[i-1].blue) *0xffffff)/(int)height2;
+#else
dr = ((int)(colors[i].red - colors[i-1].red) <<8)/(int)height2;
dg = ((int)(colors[i].green - colors[i-1].green)<<8)/(int)height2;
db = ((int)(colors[i].blue - colors[i-1].blue) <<8)/(int)height2;
+#endif
for (j=0; j<height2; j++)
{
@@ -574,9 +730,15 @@ meta_gradient_create_multi_vertical (int width, int height,
b += db;
k++;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ r = (long)(colors[i].red * 0xffffff);
+ g = (long)(colors[i].green * 0xffffff);
+ b = (long)(colors[i].blue * 0xffffff);
+#else
r = colors[i].red << 8;
g = colors[i].green << 8;
b = colors[i].blue << 8;
+#endif
}
if (k<height)
@@ -603,11 +765,17 @@ meta_gradient_create_multi_vertical (int width, int height,
return pixbuf;
}
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf*
+meta_gradient_create_multi_diagonal (int width, int height,
+ const GdkRGBA *colors,
+ int count)
+#else
static GdkPixbuf*
meta_gradient_create_multi_diagonal (int width, int height,
const GdkColor *colors,
int count)
+#endif
{
GdkPixbuf *pixbuf, *tmp;
float a, offset;
diff --git a/src/ui/gradient.h b/src/ui/gradient.h
index b65b3878..7cbe8977 100644
--- a/src/ui/gradient.h
+++ b/src/ui/gradient.h
@@ -26,6 +26,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
+#include <gtk/gtk.h>
typedef enum
{
@@ -35,6 +36,24 @@ typedef enum
META_GRADIENT_LAST
} MetaGradientType;
+#if GTK_CHECK_VERSION (3, 0 ,0)
+GdkPixbuf* meta_gradient_create_simple (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to,
+ MetaGradientType style);
+GdkPixbuf* meta_gradient_create_multi (int width,
+ int height,
+ const GdkRGBA *colors,
+ int n_colors,
+ MetaGradientType style);
+GdkPixbuf* meta_gradient_create_interwoven (int width,
+ int height,
+ const GdkRGBA colors1[2],
+ int thickness1,
+ const GdkRGBA colors2[2],
+ int thickness2);
+#else
GdkPixbuf* meta_gradient_create_simple (int width,
int height,
const GdkColor *from,
@@ -51,6 +70,7 @@ GdkPixbuf* meta_gradient_create_interwoven (int width,
int thickness1,
const GdkColor colors2[2],
int thickness2);
+#endif
/* Generate an alpha gradient and multiply it with the existing alpha
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 41abc441..1dfc7140 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -106,7 +106,11 @@ static void popup_position_func(GtkMenu* menu, gint* x, gint* y, gboolean* push_
pos = user_data;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+#else
gtk_widget_size_request(GTK_WIDGET(menu), &req);
+#endif
*x = pos->x;
*y = pos->y;
@@ -148,7 +152,7 @@ static void activate_cb(GtkWidget* menuitem, gpointer data)
md = data;
- meta_frames_notify_menu_hide(md->menu->frames);
+ meta_frames_notify_menu_hide (md->menu->frames);
(*md->menu->func)(
md->menu,
@@ -159,7 +163,7 @@ static void activate_cb(GtkWidget* menuitem, gpointer data)
GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), "workspace")),
md->menu->data);
- /* menu may now be freed */
+ /* menu may now be freed */
}
/*
@@ -389,7 +393,7 @@ meta_window_menu_new (MetaFrames *frames,
meta_verbose ("Creating %d-workspace menu current space %lu\n",
n_workspaces, active_workspace);
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(frames));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (frames));
display = GDK_WINDOW_XDISPLAY (window);
@@ -497,9 +501,10 @@ meta_window_menu_new (MetaFrames *frames,
}
}
- g_signal_connect (menu->menu, "selection_done", G_CALLBACK(menu_closed), menu);
+ g_signal_connect (menu->menu, "selection_done",
+ G_CALLBACK (menu_closed), menu);
- return menu;
+ return menu;
}
void meta_window_menu_popup(MetaWindowMenu* menu, int root_x, int root_y, int button, guint32 timestamp)
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 0bc6b42a..58122706 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -253,6 +253,66 @@ ensure_info (MetaPreview *preview)
}
#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean
+meta_preview_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaPreview *preview;
+ GtkAllocation allocation;
+ int border_width;
+ int client_width;
+ int client_height;
+ MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
+ {
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL
+ };
+
+ g_return_val_if_fail (META_IS_PREVIEW (widget), FALSE);
+
+ preview = META_PREVIEW (widget);
+
+ ensure_info (preview);
+
+ cairo_save (cr);
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_get_allocation (widget, &allocation);
+ client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
+ client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
+
+ if (client_width < 0)
+ client_width = 1;
+ if (client_height < 0)
+ client_height = 1;
+
+ if (preview->theme)
+ {
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ meta_theme_draw_frame (preview->theme,
+ widget,
+ cr,
+ preview->type,
+ preview->flags,
+ client_width, client_height,
+ preview->layout,
+ preview->text_height,
+ &preview->button_layout,
+ button_states,
+ meta_preview_get_mini_icon (),
+ meta_preview_get_icon ());
+ }
+
+ cairo_restore (cr);
+
+ /* draw child */
+ return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
+}
+
static void
meta_preview_get_preferred_width (GtkWidget *widget,
gint *minimum,
@@ -325,66 +385,6 @@ meta_preview_get_preferred_height (GtkWidget *widget,
*natural += border_width * 2;
}
-static gboolean
-meta_preview_draw(GtkWidget *widget,
- cairo_t *cr)
-{
- MetaPreview *preview;
- GtkAllocation allocation;
- int border_width;
- int client_width;
- int client_height;
- MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
- {
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL
- };
-
- g_return_val_if_fail (META_IS_PREVIEW (widget), FALSE);
-
- preview = META_PREVIEW (widget);
-
- ensure_info (preview);
-
- cairo_save (cr);
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_widget_get_allocation (widget, &allocation);
- client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
- client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
-
- if (client_width < 0)
- client_width = 1;
- if (client_height < 0)
- client_height = 1;
-
- if (preview->theme)
- {
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- meta_theme_draw_frame (preview->theme,
- widget,
- cr,
- preview->type,
- preview->flags,
- client_width, client_height,
- preview->layout,
- preview->text_height,
- &preview->button_layout,
- button_states,
- meta_preview_get_mini_icon (),
- meta_preview_get_icon ());
- }
-
- cairo_restore (cr);
-
- /* draw child */
- return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
-}
-
#else
static gboolean
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index 7dc6ec5a..977b196b 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -126,7 +126,7 @@ update_size_window (MetaResizePopup *popup)
if (gtk_widget_get_realized (popup->size_window))
{
/* using move_resize to avoid jumpiness */
- gdk_window_move_resize (gtk_widget_get_window(GTK_WIDGET(popup->size_window)),
+ gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
x, y,
width, height);
}
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index 4c4cf308..dfbdf1a4 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -81,15 +81,23 @@ static void select_workspace (GtkWidget *widget);
static void unselect_workspace (GtkWidget *widget);
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+outline_window_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
+#else
outline_window_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
+#endif
{
MetaTabPopup *popup;
TabEntry *te;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkStyle *style;
GdkWindow *window;
cairo_t *cr;
+#endif
popup = data;
@@ -97,12 +105,18 @@ outline_window_expose (GtkWidget *widget,
return FALSE;
te = popup->current_selected_entry;
+#if !GTK_CHECK_VERSION (3, 0, 0)
window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
cr = gdk_cairo_create (window);
+#endif
cairo_set_line_width (cr, 1.0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+#else
gdk_cairo_set_source_color (cr, &style->white);
+#endif
cairo_rectangle (cr,
0.5, 0.5,
@@ -116,7 +130,9 @@ outline_window_expose (GtkWidget *widget,
te->inner_rect.height + 1);
cairo_stroke (cr);
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
return FALSE;
}
@@ -236,7 +252,11 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
MetaTabPopup *popup;
int i, left, right, top, bottom;
int height;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkWidget *grid;
+#else
GtkWidget *table;
+#endif
GtkWidget *vbox;
GtkWidget *align;
GList *tmp;
@@ -258,8 +278,13 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
gtk_widget_set_app_paintable (popup->outline_window, TRUE);
gtk_widget_realize (popup->outline_window);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect (G_OBJECT (popup->outline_window), "draw",
+ G_CALLBACK (outline_window_draw), popup);
+#else
g_signal_connect (G_OBJECT (popup->outline_window), "expose_event",
G_CALLBACK (outline_window_expose), popup);
+#endif
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
@@ -290,12 +315,21 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
if (i % width)
height += 1;
- table = gtk_table_new (height, width, FALSE);
vbox = gtk_vbox_new (FALSE, 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ grid = gtk_grid_new ();
+#else
+ table = gtk_table_new (height, width, FALSE);
+#endif
+
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_container_set_border_width (GTK_CONTAINER (grid), 1);
+#else
gtk_container_set_border_width (GTK_CONTAINER (table), 1);
+#endif
gtk_container_add (GTK_CONTAINER (popup->window),
frame);
gtk_container_add (GTK_CONTAINER (frame),
@@ -305,8 +339,13 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_container_add (GTK_CONTAINER (align),
+ grid);
+#else
gtk_container_add (GTK_CONTAINER (align),
table);
+#endif
popup->label = gtk_label_new ("");
@@ -368,16 +407,24 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
te->widget = image;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_grid_attach (GTK_GRID (grid), te->widget, left, top, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (table),
te->widget,
left, right, top, bottom,
0, 0,
0, 0);
+#endif
/* Efficiency rules! */
gtk_label_set_markup (GTK_LABEL (popup->label),
te->title);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (popup->label, &req, NULL);
+#else
gtk_widget_size_request (popup->label, &req);
+#endif
max_label_width = MAX (max_label_width, req.width);
tmp = tmp->next;
@@ -431,7 +478,8 @@ meta_ui_tab_popup_free (MetaTabPopup *popup)
{
meta_verbose ("Destroying tab popup window\n");
- gtk_widget_destroy (popup->outline_window);
+ if (popup->outline_window != NULL)
+ gtk_widget_destroy (popup->outline_window);
gtk_widget_destroy (popup->window);
g_list_foreach (popup->entries, free_tab_entry, NULL);
@@ -736,7 +784,11 @@ meta_select_image_draw (GtkWidget *widget,
misc = GTK_MISC (widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
+#else
gtk_widget_get_requisition (widget, &requisition);
+#endif
gtk_misc_get_alignment (misc, &xalign, &yalign);
gtk_misc_get_padding (misc, &xpad, &ypad);
@@ -895,8 +947,8 @@ unselect_workspace (GtkWidget *widget)
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
#if GTK_CHECK_VERSION(3, 0, 0)
-static gboolean meta_select_workspace_draw (GtkWidget *widget,
- cairo_t *cr);
+static gboolean meta_select_workspace_draw (GtkWidget *widget,
+ cairo_t *cr);
#else
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event);
diff --git a/src/ui/testgradient.c b/src/ui/testgradient.c
index 8f8cd6a5..8875452d 100644
--- a/src/ui/testgradient.c
+++ b/src/ui/testgradient.c
@@ -23,12 +23,6 @@
#include "gradient.h"
#include <gtk/gtk.h>
-#ifdef __GNUC__
-#define UNUSED_VARIABLE __attribute__ ((unused))
-#else
-#define UNUSED_VARIABLE
-#endif
-
typedef void (* RenderGradientFunc) (
#if !GTK_CHECK_VERSION (3, 0, 0)
GdkDrawable *drawable,
@@ -47,14 +41,27 @@ draw_checkerboard (GdkDrawable *drawable,
int height)
{
gint i, j, xcount, ycount;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color1, color2;
+#else
GdkColor color1, color2;
-#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
#endif
#define CHECK_SIZE 10
#define SPACING 2
+#if GTK_CHECK_VERSION (3, 0, 0)
+ color1.red = 30000. / 65535.;
+ color1.green = 30000. / 65535.;
+ color1.blue = 30000. / 65535.;
+ color1.alpha = 1.0;
+
+ color2.red = 50000. / 65535.;
+ color2.green = 50000. / 65535.;
+ color2.blue = 50000. / 65535.;
+ color2.alpha = 1.0;
+#else
color1.red = 30000;
color1.green = 30000;
color1.blue = 30000;
@@ -63,7 +70,6 @@ draw_checkerboard (GdkDrawable *drawable,
color2.green = 50000;
color2.blue = 50000;
-#if !GTK_CHECK_VERSION (3, 0, 0)
cr = gdk_cairo_create (drawable);
#endif
@@ -76,9 +82,17 @@ draw_checkerboard (GdkDrawable *drawable,
while (j < height)
{
if (ycount % 2)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color1);
+#else
gdk_cairo_set_source_color (cr, &color1);
+#endif
else
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color2);
+#else
gdk_cairo_set_source_color (cr, &color2);
+#endif
/* If we're outside event->area, this will do nothing.
* It might be mildly more efficient if we handled
@@ -111,10 +125,17 @@ render_simple (
gboolean with_alpha)
{
GdkPixbuf *pixbuf;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA from, to;
+
+ gdk_rgba_parse (&from, "blue");
+ gdk_rgba_parse (&to, "green");
+#else
GdkColor from, to;
gdk_color_parse ("blue", &from);
gdk_color_parse ("green", &to);
+#endif
pixbuf = meta_gradient_create_simple (width, height,
&from, &to,
@@ -138,7 +159,7 @@ render_simple (
META_GRADIENT_HORIZONTAL);
#if GTK_CHECK_VERSION (3, 0, 0)
- draw_checkerboard (cr , width, height);
+ draw_checkerboard (cr, width, height);
#else
draw_checkerboard (drawable, width, height);
#endif
@@ -222,6 +243,16 @@ render_multi (
{
GdkPixbuf *pixbuf;
#define N_COLORS 5
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA colors[N_COLORS];
+
+ gdk_rgba_parse (&colors[0], "red");
+ gdk_rgba_parse (&colors[1], "blue");
+ gdk_rgba_parse (&colors[2], "orange");
+ gdk_rgba_parse (&colors[3], "pink");
+ gdk_rgba_parse (&colors[4], "green");
+#else
GdkColor colors[N_COLORS];
gdk_color_parse ("red", &colors[0]);
@@ -229,6 +260,7 @@ render_multi (
gdk_color_parse ("orange", &colors[2]);
gdk_color_parse ("pink", &colors[3]);
gdk_color_parse ("green", &colors[4]);
+#endif
pixbuf = meta_gradient_create_multi (width, height,
colors, N_COLORS,
@@ -297,12 +329,22 @@ render_interwoven_func (
{
GdkPixbuf *pixbuf;
#define N_COLORS 4
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA colors[N_COLORS];
+
+ gdk_rgba_parse (&colors[0], "red");
+ gdk_rgba_parse (&colors[1], "blue");
+ gdk_rgba_parse (&colors[2], "pink");
+ gdk_rgba_parse (&colors[3], "green");
+#else
GdkColor colors[N_COLORS];
gdk_color_parse ("red", &colors[0]);
gdk_color_parse ("blue", &colors[1]);
gdk_color_parse ("pink", &colors[2]);
gdk_color_parse ("green", &colors[3]);
+#endif
pixbuf = meta_gradient_create_interwoven (width, height,
colors, height / 10,
@@ -327,21 +369,34 @@ expose_callback (GtkWidget *widget,
#endif
{
RenderGradientFunc func = data;
- GdkWindow *window;
GtkAllocation allocation;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *style;
+ GdkRGBA color;
+
+ style = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, gtk_widget_get_state_flags (widget));
+ gtk_style_context_lookup_color (style, "foreground-color", &color);
+ gtk_style_context_restore (style);
+#else
+ GdkWindow *window;
GtkStyle *style;
-#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
-#endif
style = gtk_widget_get_style (widget);
+#endif
+
gtk_widget_get_allocation (widget, &allocation);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
+#else
window = gtk_widget_get_window (widget);
-#if !GTK_CHECK_VERSION (3, 0, 0)
cr = gdk_cairo_create (window);
-#endif
gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]);
+#endif
(* func) (
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -399,31 +454,29 @@ create_gradient_window (const char *title,
static void
meta_gradient_test (void)
{
- GtkWidget UNUSED_VARIABLE *window;
-
- window = create_gradient_window ("Simple vertical",
- render_vertical_func);
+ create_gradient_window ("Simple vertical",
+ render_vertical_func);
- window = create_gradient_window ("Simple horizontal",
- render_horizontal_func);
+ create_gradient_window ("Simple horizontal",
+ render_horizontal_func);
- window = create_gradient_window ("Simple diagonal",
- render_diagonal_func);
+ create_gradient_window ("Simple diagonal",
+ render_diagonal_func);
- window = create_gradient_window ("Multi vertical",
- render_vertical_multi_func);
+ create_gradient_window ("Multi vertical",
+ render_vertical_multi_func);
- window = create_gradient_window ("Multi horizontal",
- render_horizontal_multi_func);
+ create_gradient_window ("Multi horizontal",
+ render_horizontal_multi_func);
- window = create_gradient_window ("Multi diagonal",
- render_diagonal_multi_func);
+ create_gradient_window ("Multi diagonal",
+ render_diagonal_multi_func);
- window = create_gradient_window ("Interwoven",
- render_interwoven_func);
+ create_gradient_window ("Interwoven",
+ render_interwoven_func);
- window = create_gradient_window ("Simple diagonal with horizontal multi alpha",
- render_diagonal_alpha_func);
+ create_gradient_window ("Simple diagonal with horizontal multi alpha",
+ render_diagonal_alpha_func);
}
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index dccb47ad..f60c7619 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -190,12 +190,12 @@ static void parse_shadow_element (GMarkupParseContext *context,
ParseInfo *info,
GError **error);
-static void parse_padding_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- ParseInfo *info,
- GError **error);
+static void parse_padding_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseInfo *info,
+ GError **error);
#endif
static void parse_menu_icon_element (GMarkupParseContext *context,
const gchar *element_name,
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 2e13fd25..a7dc8d08 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -63,6 +63,23 @@
#define __USE_XOPEN
#include <math.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h>
+#endif
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define GDK_COLOR_RGBA(color) \
+ ((guint32) (0xff | \
+ ((int)((color).red * 255) << 24) | \
+ ((int)((color).green * 255) << 16) | \
+ ((int)((color).blue * 255) << 8)))
+
+#define GDK_COLOR_RGB(color) \
+ ((guint32) (((int)((color).red * 255) << 16) | \
+ ((int)((color).green * 255) << 8) | \
+ ((int)((color).blue * 255))))
+#else
#define GDK_COLOR_RGBA(color) \
((guint32) (0xff | \
(((color).red / 256) << 24) | \
@@ -73,6 +90,7 @@
((guint32) ((((color).red / 256) << 16) | \
(((color).green / 256) << 8) | \
(((color).blue / 256))))
+#endif
#define ALPHA_TO_UCHAR(d) ((unsigned char) ((d) * 255))
@@ -80,9 +98,15 @@
#define CLAMP_UCHAR(v) ((guchar) (CLAMP (((int)v), (int)0, (int)255)))
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void gtk_style_shade (GdkRGBA *a,
+ GdkRGBA *b,
+ gdouble k);
+#else
static void gtk_style_shade (GdkColor *a,
GdkColor *b,
gdouble k);
+#endif
static void rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b);
@@ -95,9 +119,15 @@ static void hls_to_rgb (gdouble *h,
*/
static MetaTheme *meta_current_theme = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GdkPixbuf *
+colorize_pixbuf (GdkPixbuf *orig,
+ GdkRGBA *new_color)
+#else
static GdkPixbuf *
colorize_pixbuf (GdkPixbuf *orig,
GdkColor *new_color)
+#endif
{
GdkPixbuf *pixbuf;
double intensity;
@@ -140,16 +170,28 @@ colorize_pixbuf (GdkPixbuf *orig,
if (intensity <= 0.5)
{
/* Go from black at intensity = 0.0 to new_color at intensity = 0.5 */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ dr = new_color->red * intensity * 2.0;
+ dg = new_color->green * intensity * 2.0;
+ db = new_color->blue * intensity * 2.0;
+#else
dr = (new_color->red * intensity * 2.0) / 65535.0;
dg = (new_color->green * intensity * 2.0) / 65535.0;
db = (new_color->blue * intensity * 2.0) / 65535.0;
+#endif
}
else
{
/* Go from new_color at intensity = 0.5 to white at intensity = 1.0 */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ dr = new_color->red + (1.0 - new_color->red) * (intensity - 0.5) * 2.0;
+ dg = new_color->green + (1.0 - new_color->green) * (intensity - 0.5) * 2.0;
+ db = new_color->blue + (1.0 - new_color->blue) * (intensity - 0.5) * 2.0;
+#else
dr = (new_color->red + (65535 - new_color->red) * (intensity - 0.5) * 2.0) / 65535.0;
dg = (new_color->green + (65535 - new_color->green) * (intensity - 0.5) * 2.0) / 65535.0;
db = (new_color->blue + (65535 - new_color->blue) * (intensity - 0.5) * 2.0) / 65535.0;
+#endif
}
dest[0] = CLAMP_UCHAR (255 * dr);
@@ -173,6 +215,19 @@ colorize_pixbuf (GdkPixbuf *orig,
return pixbuf;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+color_composite (const GdkRGBA *bg,
+ const GdkRGBA *fg,
+ double alpha,
+ GdkRGBA *color)
+{
+ *color = *bg;
+ color->red = color->red + (fg->red - color->red) * alpha;
+ color->green = color->green + (fg->green - color->green) * alpha;
+ color->blue = color->blue + (fg->blue - color->blue) * alpha;
+}
+#else
static void
color_composite (const GdkColor *bg,
const GdkColor *fg,
@@ -187,6 +242,7 @@ color_composite (const GdkColor *bg,
color->green = color->green + (((fg->green - color->green) * alpha + 0x8000) >> 16);
color->blue = color->blue + (((fg->blue - color->blue) * alpha + 0x8000) >> 16);
}
+#endif
/**
* Sets all the fields of a border to dummy values.
@@ -939,7 +995,6 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
-
x = rect->visible.x + rect->visible.width + layout->button_border.right;
if (left_buttons_has_spacer[i])
x += (button_width * 0.75);
@@ -1015,14 +1070,26 @@ meta_gradient_spec_free (MetaGradientSpec *spec)
g_free (spec);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf*
+meta_gradient_spec_render (const MetaGradientSpec *spec,
+ GtkStyleContext *style,
+ int width,
+ int height)
+#else
GdkPixbuf*
meta_gradient_spec_render (const MetaGradientSpec *spec,
- GtkWidget *widget,
+ GtkStyle *style,
int width,
int height)
+#endif
{
int n_colors;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *colors;
+#else
GdkColor *colors;
+#endif
GSList *tmp;
int i;
GdkPixbuf *pixbuf;
@@ -1032,13 +1099,17 @@ meta_gradient_spec_render (const MetaGradientSpec *spec,
if (n_colors == 0)
return NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ colors = g_new (GdkRGBA, n_colors);
+#else
colors = g_new (GdkColor, n_colors);
+#endif
i = 0;
tmp = spec->color_specs;
while (tmp != NULL)
{
- meta_color_spec_render (tmp->data, widget, &colors[i]);
+ meta_color_spec_render (tmp->data, style, &colors[i]);
tmp = tmp->next;
++i;
@@ -1178,7 +1249,11 @@ meta_color_spec_new_from_string (const char *str,
const char *bracket;
const char *end_bracket;
char *tmp;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStateFlags state;
+#else
GtkStateType state;
+#endif
MetaGtkColorComponent component;
bracket = str;
@@ -1371,7 +1446,11 @@ meta_color_spec_new_from_string (const char *str,
{
spec = meta_color_spec_new (META_COLOR_SPEC_BASIC);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (!gdk_rgba_parse (&spec->data.basic.color, str))
+#else
if (!gdk_color_parse (str, &spec->data.basic.color))
+#endif
{
g_set_error (err, META_THEME_ERROR,
META_THEME_ERROR_FAILED,
@@ -1387,9 +1466,15 @@ meta_color_spec_new_from_string (const char *str,
return spec;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+MetaColorSpec*
+meta_color_spec_new_gtk (MetaGtkColorComponent component,
+ GtkStateFlags state)
+#else
MetaColorSpec*
meta_color_spec_new_gtk (MetaGtkColorComponent component,
GtkStateType state)
+#endif
{
MetaColorSpec *spec;
@@ -1401,18 +1486,111 @@ meta_color_spec_new_gtk (MetaGtkColorComponent component,
return spec;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+meta_set_color_from_style (GdkRGBA *color,
+ GtkStyleContext *context,
+ GtkStateFlags state,
+ MetaGtkColorComponent component)
+{
+ GdkRGBA other;
+
+ switch (component)
+ {
+ case META_GTK_COLOR_BG:
+ case META_GTK_COLOR_BASE:
+ gtk_style_context_get_background_color (context, state, color);
+ break;
+ case META_GTK_COLOR_FG:
+ case META_GTK_COLOR_TEXT:
+ gtk_style_context_get_color (context, state, color);
+ break;
+ case META_GTK_COLOR_TEXT_AA:
+ gtk_style_context_get_color (context, state, color);
+ meta_set_color_from_style (&other, context, state, META_GTK_COLOR_BASE);
+
+ color->red = (color->red + other.red) / 2;
+ color->green = (color->green + other.green) / 2;
+ color->blue = (color->blue + other.blue) / 2;
+ break;
+ case META_GTK_COLOR_MID:
+ mate_desktop_gtk_style_get_light_color (context, state, color);
+ mate_desktop_gtk_style_get_dark_color (context, state, &other);
+
+ color->red = (color->red + other.red) / 2;
+ color->green = (color->green + other.green) / 2;
+ color->blue = (color->blue + other.blue) / 2;
+ break;
+ case META_GTK_COLOR_LIGHT:
+ mate_desktop_gtk_style_get_light_color (context, state, color);
+ break;
+ case META_GTK_COLOR_DARK:
+ mate_desktop_gtk_style_get_dark_color (context, state, color);
+ break;
+ case META_GTK_COLOR_LAST:
+ g_assert_not_reached ();
+ break;
+ }
+}
+#else
+static void
+meta_set_color_from_style (GdkColor *color,
+ GtkStyle *widget_style,
+ GtkStateType state,
+ MetaGtkColorComponent component)
+{
+ switch (component)
+ {
+ case META_GTK_COLOR_BG:
+ *color = widget_style->bg[state];
+ break;
+ case META_GTK_COLOR_FG:
+ *color = widget_style->fg[state];
+ break;
+ case META_GTK_COLOR_BASE:
+ *color = widget_style->base[state];
+ break;
+ case META_GTK_COLOR_TEXT:
+ *color = widget_style->text[state];
+ break;
+ case META_GTK_COLOR_LIGHT:
+ *color = widget_style->light[state];
+ break;
+ case META_GTK_COLOR_DARK:
+ *color = widget_style->dark[state];
+ break;
+ case META_GTK_COLOR_MID:
+ *color = widget_style->mid[state];
+ break;
+ case META_GTK_COLOR_TEXT_AA:
+ *color = widget_style->text_aa[state];
+ break;
+ case META_GTK_COLOR_LAST:
+ g_assert_not_reached ();
+ break;
+ }
+}
+#endif
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+void
+meta_color_spec_render (MetaColorSpec *spec,
+ GtkStyleContext *style,
+ GdkRGBA *color)
+#else
void
meta_color_spec_render (MetaColorSpec *spec,
- GtkWidget *widget,
+ GtkStyle *style,
GdkColor *color)
+#endif
{
- GtkStyle *widget_style;
-
g_return_if_fail (spec != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
- widget_style = gtk_widget_get_style (widget);
- g_return_if_fail (widget_style != NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (style));
+#else
+ g_return_if_fail (style != NULL);
+#endif
switch (spec->type)
{
@@ -1421,44 +1599,22 @@ meta_color_spec_render (MetaColorSpec *spec,
break;
case META_COLOR_SPEC_GTK:
- switch (spec->data.gtk.component)
- {
- case META_GTK_COLOR_BG:
- *color = widget_style->bg[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_FG:
- *color = widget_style->fg[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_BASE:
- *color = widget_style->base[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_TEXT:
- *color = widget_style->text[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_LIGHT:
- *color = widget_style->light[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_DARK:
- *color = widget_style->dark[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_MID:
- *color = widget_style->mid[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_TEXT_AA:
- *color = widget_style->text_aa[spec->data.gtk.state];
- break;
- case META_GTK_COLOR_LAST:
- g_assert_not_reached ();
- break;
- }
+ meta_set_color_from_style (color,
+ style,
+ spec->data.gtk.state,
+ spec->data.gtk.component);
break;
case META_COLOR_SPEC_BLEND:
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA bg, fg;
+#else
GdkColor bg, fg;
+#endif
- meta_color_spec_render (spec->data.blend.background, widget, &bg);
- meta_color_spec_render (spec->data.blend.foreground, widget, &fg);
+ meta_color_spec_render (spec->data.blend.background, style, &bg);
+ meta_color_spec_render (spec->data.blend.foreground, style, &fg);
color_composite (&bg, &fg, spec->data.blend.alpha,
&spec->data.blend.color);
@@ -1469,7 +1625,7 @@ meta_color_spec_render (MetaColorSpec *spec,
case META_COLOR_SPEC_SHADE:
{
- meta_color_spec_render (spec->data.shade.base, widget,
+ meta_color_spec_render (spec->data.shade.base, style,
&spec->data.shade.color);
gtk_style_shade (&spec->data.shade.color,
@@ -3215,7 +3371,11 @@ scale_and_alpha_pixbuf (GdkPixbuf *src,
static GdkPixbuf*
draw_op_as_pixbuf (const MetaDrawOp *op,
- GtkWidget *widget,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *style,
+#else
+ GtkStyle *style,
+#endif
const MetaDrawInfo *info,
int width,
int height)
@@ -3236,10 +3396,14 @@ draw_op_as_pixbuf (const MetaDrawOp *op,
case META_DRAW_RECTANGLE:
if (op->data.rectangle.filled)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
meta_color_spec_render (op->data.rectangle.color_spec,
- widget,
+ style,
&color);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
@@ -3258,12 +3422,16 @@ draw_op_as_pixbuf (const MetaDrawOp *op,
case META_DRAW_TINT:
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
guint32 rgba;
gboolean has_alpha;
meta_color_spec_render (op->data.rectangle.color_spec,
- widget,
+ style,
&color);
has_alpha =
@@ -3306,7 +3474,7 @@ draw_op_as_pixbuf (const MetaDrawOp *op,
case META_DRAW_GRADIENT:
{
pixbuf = meta_gradient_spec_render (op->data.gradient.gradient_spec,
- widget, width, height);
+ style, width, height);
pixbuf = apply_alpha (pixbuf,
op->data.gradient.alpha_spec,
@@ -3319,10 +3487,14 @@ draw_op_as_pixbuf (const MetaDrawOp *op,
{
if (op->data.image.colorize_spec)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
meta_color_spec_render (op->data.image.colorize_spec,
- widget, &color);
+ style, &color);
if (op->data.image.colorize_cache_pixbuf == NULL ||
op->data.image.colorize_cache_pixel != GDK_COLOR_RGB (color))
@@ -3430,31 +3602,6 @@ fill_env (MetaPositionExprEnv *env,
env->theme = meta_current_theme;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
-static GtkStateFlags
-state_flags_from_gtk_state (GtkStateType state)
-{
- switch (state)
- {
- case GTK_STATE_NORMAL:
- return 0;
- case GTK_STATE_PRELIGHT:
- return GTK_STATE_FLAG_PRELIGHT;
- case GTK_STATE_ACTIVE:
- return GTK_STATE_FLAG_ACTIVE;
- case GTK_STATE_SELECTED:
- return GTK_STATE_FLAG_SELECTED;
- case GTK_STATE_INSENSITIVE:
- return GTK_STATE_FLAG_INSENSITIVE;
- case GTK_STATE_INCONSISTENT:
- return GTK_STATE_FLAG_INCONSISTENT;
- case GTK_STATE_FOCUSED:
- return GTK_STATE_FLAG_FOCUSED;
- }
- return 0;
-}
-#endif
-
/* This code was originally rendering anti-aliased using X primitives, and
* now has been switched to draw anti-aliased using cairo. In general, the
* closest correspondence between X rendering and cairo rendering is given
@@ -3470,13 +3617,9 @@ static void
meta_draw_op_draw_with_env (const MetaDrawOp *op,
#if GTK_CHECK_VERSION(3, 0, 0)
GtkStyleContext *style_gtk,
- #else
- GtkStyle *style_gtk,
- #endif
- GtkWidget *widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
#endif
@@ -3484,12 +3627,15 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
MetaRectangle rect,
MetaPositionExprEnv *env)
{
- GdkColor color;
-
#if GTK_CHECK_VERSION(3, 0, 0)
- cairo_save(cr);
- gtk_style_context_save(style_gtk);
+ GdkRGBA color;
+
+ cairo_save (cr);
+ gtk_style_context_save (style_gtk);
#else
+ GdkColor color;
+ GtkStyle *style_gtk = gtk_widget_get_style (widget);
+
cairo_t *cr;
cr = gdk_cairo_create (drawable);
#endif
@@ -3510,8 +3656,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
{
int x1, x2, y1, y2;
- meta_color_spec_render (op->data.line.color_spec, widget, &color);
+ meta_color_spec_render (op->data.line.color_spec, style_gtk, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
if (op->data.line.width > 0)
cairo_set_line_width (cr, op->data.line.width);
@@ -3598,8 +3748,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
{
int rx, ry, rwidth, rheight;
- meta_color_spec_render (op->data.rectangle.color_spec, widget, &color);
+ meta_color_spec_render (op->data.rectangle.color_spec, style_gtk, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
rx = parse_x_position_unchecked (op->data.rectangle.x, env);
ry = parse_y_position_unchecked (op->data.rectangle.y, env);
@@ -3628,8 +3782,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
double start_angle, end_angle;
double center_x, center_y;
- meta_color_spec_render (op->data.arc.color_spec, widget, &color);
+ meta_color_spec_render (op->data.arc.color_spec, style_gtk, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
rx = parse_x_position_unchecked (op->data.arc.x, env);
ry = parse_y_position_unchecked (op->data.arc.y, env);
@@ -3683,8 +3841,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
if (!needs_alpha)
{
- meta_color_spec_render (op->data.tint.color_spec, widget, &color);
+ meta_color_spec_render (op->data.tint.color_spec, style_gtk, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
cairo_rectangle (cr, rx, ry, rwidth, rheight);
cairo_fill (cr);
@@ -3693,7 +3855,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
{
GdkPixbuf *pixbuf;
- pixbuf = draw_op_as_pixbuf (op, widget, info,
+ pixbuf = draw_op_as_pixbuf (op, style_gtk, info,
rwidth, rheight);
if (pixbuf)
@@ -3717,7 +3879,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.gradient.width, env);
rheight = parse_size_unchecked (op->data.gradient.height, env);
- pixbuf = draw_op_as_pixbuf (op, widget, info,
+ pixbuf = draw_op_as_pixbuf (op, style_gtk, info,
rwidth, rheight);
if (pixbuf)
@@ -3744,7 +3906,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.image.width, env);
rheight = parse_size_unchecked (op->data.image.height, env);
- pixbuf = draw_op_as_pixbuf (op, widget, info,
+ pixbuf = draw_op_as_pixbuf (op, style_gtk, info,
rwidth, rheight);
if (pixbuf)
@@ -3791,8 +3953,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
return;
}
- gtk_style_context_set_state (style_gtk,
- state_flags_from_gtk_state (op->data.gtk_arrow.state));
+ gtk_style_context_set_state (style_gtk, op->data.gtk_arrow.state);
gtk_render_arrow (style_gtk, cr, angle, rx, ry, size);
#else
@@ -3821,8 +3982,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rheight = parse_size_unchecked (op->data.gtk_box.height, env);
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_style_context_set_state (style_gtk,
- state_flags_from_gtk_state (op->data.gtk_box.state));
+ gtk_style_context_set_state (style_gtk, op->data.gtk_box.state);
gtk_render_background (style_gtk, cr, rx, ry, rwidth, rheight);
gtk_render_frame (style_gtk, cr, rx, ry, rwidth, rheight);
#else
@@ -3847,8 +4007,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
ry2 = parse_y_position_unchecked (op->data.gtk_vline.y2, env);
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_style_context_set_state (style_gtk,
- state_flags_from_gtk_state (op->data.gtk_vline.state));
+ gtk_style_context_set_state (style_gtk, op->data.gtk_vline.state);
gtk_render_line (style_gtk, cr, rx, ry1, rx, ry2);
#else
gtk_paint_vline (style_gtk,
@@ -3870,7 +4029,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.icon.width, env);
rheight = parse_size_unchecked (op->data.icon.height, env);
- pixbuf = draw_op_as_pixbuf (op, widget, info,
+ pixbuf = draw_op_as_pixbuf (op, style_gtk, info,
rwidth, rheight);
if (pixbuf)
@@ -3891,8 +4050,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
{
int rx, ry;
- meta_color_spec_render (op->data.title.color_spec, widget, &color);
+ meta_color_spec_render (op->data.title.color_spec, style_gtk, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
rx = parse_x_position_unchecked (op->data.title.x, env);
ry = parse_y_position_unchecked (op->data.title.y, env);
@@ -3908,6 +4071,20 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
cairo_pattern_t *linpat;
linpat = cairo_pattern_create_linear (rx, ry, text_space,
env->title_height);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_add_color_stop_rgba (linpat, 0, color.red,
+ color.green,
+ color.blue,
+ color.alpha);
+ cairo_pattern_add_color_stop_rgba (linpat, startalpha,
+ color.red,
+ color.green,
+ color.blue,
+ color.alpha);
+ cairo_pattern_add_color_stop_rgba (linpat, 1, color.red,
+ color.green,
+ color.blue, 0);
+#else
cairo_pattern_add_color_stop_rgb (linpat, 0, color.red/65535.0,
color.green/65535.0,
color.blue/65535.0);
@@ -3918,10 +4095,15 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
cairo_pattern_add_color_stop_rgba (linpat, 1, color.red/65535.0,
color.green/65535.0,
color.blue/65535.0, 0);
+#endif
cairo_set_source(cr, linpat);
cairo_pattern_destroy(linpat);
} else {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
gdk_cairo_set_source_color (cr, &color);
+#endif
}
cairo_move_to (cr, rx, ry);
@@ -3939,10 +4121,11 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
d_rect.height = parse_size_unchecked (op->data.op_list.height, env);
meta_draw_op_list_draw_with_style (op->data.op_list.op_list,
- style_gtk, widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ style_gtk,
cr,
#else
+ widget,
drawable, clip,
#endif
info, d_rect);
@@ -3986,7 +4169,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
while (tile.y < (ry + rheight))
{
meta_draw_op_list_draw_with_style (op->data.tile.op_list,
- style_gtk, widget, cr, info,
+ style_gtk, cr, info,
tile);
tile.y += tile.height;
@@ -4023,7 +4206,11 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
while (tile.y < (ry + rheight))
{
meta_draw_op_list_draw_with_style (op->data.tile.op_list,
- style_gtk, widget, drawable, &new_clip, info,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ style_gtk, drawable, &new_clip, info,
+#else
+ widget, drawable, &new_clip, info,
+#endif
tile);
tile.y += tile.height;
@@ -4047,11 +4234,11 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
void
meta_draw_op_draw_with_style (const MetaDrawOp *op,
- GtkStyle *style_gtk,
- GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
#endif
@@ -4060,16 +4247,14 @@ meta_draw_op_draw_with_style (const MetaDrawOp *op,
{
MetaPositionExprEnv env;
- #if !GTK_CHECK_VERSION(3, 0, 0)
- g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
- #endif
-
fill_env (&env, info, logical_region);
- meta_draw_op_draw_with_env (op, style_gtk, widget,
+ meta_draw_op_draw_with_env (op,
#if GTK_CHECK_VERSION(3, 0, 0)
+ style_gtk,
cr,
#else
+ widget,
drawable, clip,
#endif
info, logical_region,
@@ -4089,10 +4274,12 @@ meta_draw_op_draw (const MetaDrawOp *op,
const MetaDrawInfo *info,
MetaRectangle logical_region)
{
- meta_draw_op_draw_with_style (op, gtk_widget_get_style (widget), widget,
+ meta_draw_op_draw_with_style (op,
#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_get_style_context (widget),
cr,
#else
+ widget,
drawable, clip,
#endif
info, logical_region);
@@ -4147,11 +4334,11 @@ meta_draw_op_list_unref (MetaDrawOpList *op_list)
void
meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
- GtkStyle *style_gtk,
- GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
#endif
@@ -4167,10 +4354,6 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
#endif
MetaPositionExprEnv env;
- #if !GTK_CHECK_VERSION(3, 0, 0)
- g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
- #endif
-
if (op_list->n_ops == 0)
return;
@@ -4189,7 +4372,7 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
*/
#if GTK_CHECK_VERSION(3, 0, 0)
- cairo_save(cr);
+ cairo_save (cr);
#else
if (clip)
{
@@ -4226,10 +4409,7 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
}
else if (gdk_cairo_get_clip_rectangle (cr, NULL))
{
- meta_draw_op_draw_with_env (op,
- style_gtk, widget, cr, info,
- rect,
- &env);
+ meta_draw_op_draw_with_env (op, style_gtk, cr, info, rect, &env);
}
#else
@@ -4247,7 +4427,7 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
active_clip.height > 0)
{
meta_draw_op_draw_with_env (op,
- style_gtk, widget, drawable, &active_clip, info,
+ widget, drawable, &active_clip, info,
rect,
&env);
}
@@ -4255,7 +4435,7 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
}
#if GTK_CHECK_VERSION(3, 0, 0)
- cairo_restore(cr);
+ cairo_restore (cr);
#endif
}
@@ -4272,10 +4452,12 @@ meta_draw_op_list_draw (const MetaDrawOpList *op_list,
MetaRectangle rect)
{
- meta_draw_op_list_draw_with_style (op_list, gtk_widget_get_style (widget), widget,
+ meta_draw_op_list_draw_with_style (op_list,
#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_get_style_context (widget),
cr,
#else
+ widget,
drawable, clip,
#endif
info, rect);
@@ -4644,13 +4826,9 @@ void
meta_frame_style_draw_with_style (MetaFrameStyle *style,
#if GTK_CHECK_VERSION(3, 0, 0)
GtkStyleContext *style_gtk,
- #else
- GtkStyle *style_gtk,
- #endif
- GtkWidget *widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
int x_offset,
int y_offset,
@@ -4676,10 +4854,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
PangoRectangle extents;
MetaDrawInfo draw_info;
- #if !GTK_CHECK_VERSION(3, 0, 0)
- g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
- #endif
-
titlebar_rect.x = 0;
titlebar_rect.y = 0;
titlebar_rect.width = fgeom->width;
@@ -4831,7 +5005,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
m_rect = meta_rect (rect.x, rect.y, rect.width, rect.height);
meta_draw_op_list_draw_with_style (op_list,
style_gtk,
- widget,
cr,
&draw_info,
m_rect);
@@ -4870,7 +5043,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
MetaRectangle m_rect;
m_rect = meta_rect (rect.x, rect.y, rect.width, rect.height);
meta_draw_op_list_draw_with_style (op_list,
- style_gtk,
widget,
drawable,
&combined_clip,
@@ -4916,7 +5088,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
meta_draw_op_list_draw_with_style (op_list,
style_gtk,
- widget,
cr,
&draw_info,
m_rect);
@@ -4978,7 +5149,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
m_rect = meta_rect (rect.x, rect.y,
rect.width, rect.height);
meta_draw_op_list_draw_with_style (op_list,
- style_gtk,
widget,
drawable,
&combined_clip,
@@ -5031,13 +5201,9 @@ meta_frame_style_draw (MetaFrameStyle *style,
meta_frame_style_draw_with_style (style,
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_get_style_context (widget),
- #else
- gtk_widget_get_style (widget),
- #endif
- widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cr,
#else
+ widget,
drawable, x_offset, y_offset, clip,
#endif
fgeom, client_width, client_height,
@@ -5636,13 +5802,9 @@ void
meta_theme_draw_frame_with_style (MetaTheme *theme,
#if GTK_CHECK_VERSION(3, 0, 0)
GtkStyleContext *style_gtk,
- #else
- GtkStyle *style_gtk,
- #endif
- GtkWidget *widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
@@ -5679,11 +5841,11 @@ meta_theme_draw_frame_with_style (MetaTheme *theme,
theme);
meta_frame_style_draw_with_style (style,
- style_gtk,
- widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ style_gtk,
cr,
#else
+ widget,
drawable, x_offset, y_offset, clip,
#endif
&fgeom,
@@ -5719,13 +5881,9 @@ meta_theme_draw_frame (MetaTheme *theme,
meta_theme_draw_frame_with_style (theme,
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_get_style_context (widget),
- #else
- gtk_widget_get_style (widget),
- #endif
- widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cr,
#else
+ widget,
drawable, clip, x_offset, y_offset,
#endif
type, flags, client_width, client_height,
@@ -6128,7 +6286,14 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget,
g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *style = gtk_widget_get_style_context (widget);
+ GtkStateFlags state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_get(style, state, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
+ font_desc = pango_font_description_copy (font_desc);
+#else
font_desc = pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
+#endif
if (override)
pango_font_description_merge (font_desc, override, TRUE);
@@ -6596,6 +6761,30 @@ meta_gradient_type_to_string (MetaGradientType type)
return "<unknown>";
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+GtkStateFlags
+meta_gtk_state_from_string (const char *str)
+{
+ if (g_ascii_strcasecmp ("normal", str) == 0)
+ return GTK_STATE_FLAG_NORMAL;
+ else if (g_ascii_strcasecmp ("prelight", str) == 0)
+ return GTK_STATE_FLAG_PRELIGHT;
+ else if (g_ascii_strcasecmp ("active", str) == 0)
+ return GTK_STATE_FLAG_ACTIVE;
+ else if (g_ascii_strcasecmp ("selected", str) == 0)
+ return GTK_STATE_FLAG_SELECTED;
+ else if (g_ascii_strcasecmp ("insensitive", str) == 0)
+ return GTK_STATE_FLAG_INSENSITIVE;
+ else if (g_ascii_strcasecmp ("inconsistent", str) == 0)
+ return GTK_STATE_FLAG_INCONSISTENT;
+ else if (g_ascii_strcasecmp ("focused", str) == 0)
+ return GTK_STATE_FLAG_FOCUSED;
+ else if (g_ascii_strcasecmp ("backdrop", str) == 0)
+ return GTK_STATE_FLAG_BACKDROP;
+ else
+ return -1; /* hack */
+}
+#else
GtkStateType
meta_gtk_state_from_string (const char *str)
{
@@ -6632,6 +6821,7 @@ meta_gtk_state_to_string (GtkStateType state)
return "<unknown>";
}
+#endif
GtkShadowType
meta_gtk_shadow_from_string (const char *str)
@@ -6755,18 +6945,31 @@ meta_image_fill_type_to_string (MetaImageFillType fill_type)
* \param b [out] the resulting colour
* \param k amount to scale lightness and saturation by
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+gtk_style_shade (GdkRGBA *a,
+ GdkRGBA *b,
+ gdouble k)
+#else
static void
gtk_style_shade (GdkColor *a,
GdkColor *b,
gdouble k)
+#endif
{
gdouble red;
gdouble green;
gdouble blue;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ red = a->red;
+ green = a->green;
+ blue = a->blue;
+#else
red = (gdouble) a->red / 65535.0;
green = (gdouble) a->green / 65535.0;
blue = (gdouble) a->blue / 65535.0;
+#endif
rgb_to_hls (&red, &green, &blue);
@@ -6784,9 +6987,15 @@ gtk_style_shade (GdkColor *a,
hls_to_rgb (&red, &green, &blue);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ b->red = red;
+ b->green = green;
+ b->blue = blue;
+#else
b->red = red * 65535.0;
b->green = green * 65535.0;
b->blue = blue * 65535.0;
+#endif
}
/**
diff --git a/src/ui/theme.h b/src/ui/theme.h
index a4ddb5f6..66996d89 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -255,24 +255,40 @@ struct _MetaColorSpec
union
{
struct {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
} basic;
struct {
MetaGtkColorComponent component;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStateFlags state;
+#else
GtkStateType state;
+#endif
} gtk;
struct {
MetaColorSpec *foreground;
MetaColorSpec *background;
double alpha;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
} blend;
struct {
MetaColorSpec *base;
double factor;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
} shade;
} data;
};
@@ -501,7 +517,11 @@ struct _MetaDrawOp
} image;
struct {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStateFlags state;
+#else
GtkStateType state;
+#endif
GtkShadowType shadow;
GtkArrowType arrow;
gboolean filled;
@@ -513,7 +533,11 @@ struct _MetaDrawOp
} gtk_arrow;
struct {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStateFlags state;
+#else
GtkStateType state;
+#endif
GtkShadowType shadow;
MetaDrawSpec *x;
MetaDrawSpec *y;
@@ -522,7 +546,11 @@ struct _MetaDrawOp
} gtk_box;
struct {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStateFlags state;
+#else
GtkStateType state;
+#endif
MetaDrawSpec *x;
MetaDrawSpec *y1;
MetaDrawSpec *y2;
@@ -898,12 +926,23 @@ void meta_draw_spec_free (MetaDrawSpec *spec);
MetaColorSpec* meta_color_spec_new (MetaColorSpecType type);
MetaColorSpec* meta_color_spec_new_from_string (const char *str,
GError **err);
+#if GTK_CHECK_VERSION (3, 0, 0)
+MetaColorSpec* meta_color_spec_new_gtk (MetaGtkColorComponent component,
+ GtkStateFlags state);
+#else
MetaColorSpec* meta_color_spec_new_gtk (MetaGtkColorComponent component,
GtkStateType state);
+#endif
void meta_color_spec_free (MetaColorSpec *spec);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void meta_color_spec_render (MetaColorSpec *spec,
+ GtkStyleContext *style_gtk,
+ GdkRGBA *color);
+#else
void meta_color_spec_render (MetaColorSpec *spec,
- GtkWidget *widget,
+ GtkStyle *style_gtk,
GdkColor *color);
+#endif
MetaDrawOp* meta_draw_op_new (MetaDrawType type);
@@ -921,11 +960,11 @@ void meta_draw_op_draw (const MetaDrawOp *op,
MetaRectangle logical_region);
void meta_draw_op_draw_with_style (const MetaDrawOp *op,
- GtkStyle *style_gtk,
- GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
#endif
@@ -947,11 +986,11 @@ void meta_draw_op_list_draw (const MetaDrawOpList *op_list,
const MetaDrawInfo *info,
MetaRectangle rect);
void meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
- GtkStyle *style_gtk,
- GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
#endif
@@ -966,10 +1005,17 @@ gboolean meta_draw_op_list_contains (MetaDrawOpList *op_list,
MetaGradientSpec* meta_gradient_spec_new (MetaGradientType type);
void meta_gradient_spec_free (MetaGradientSpec *desc);
+#if GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf* meta_gradient_spec_render (const MetaGradientSpec *desc,
- GtkWidget *widget,
+ GtkStyleContext *style_gtk,
int width,
int height);
+#else
+GdkPixbuf* meta_gradient_spec_render (const MetaGradientSpec *desc,
+ GtkStyle *style_gtk,
+ int width,
+ int height);
+#endif
gboolean meta_gradient_spec_validate (MetaGradientSpec *spec,
GError **error);
@@ -1005,13 +1051,9 @@ void meta_frame_style_draw (MetaFrameStyle *style,
void meta_frame_style_draw_with_style (MetaFrameStyle *style,
#if GTK_CHECK_VERSION(3, 0, 0)
GtkStyleContext *style_gtk,
- #else
- GtkStyle *style_gtk,
- #endif
- GtkWidget *widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
int x_offset,
int y_offset,
@@ -1104,13 +1146,9 @@ void meta_theme_draw_frame_by_name (MetaTheme *theme,
void meta_theme_draw_frame_with_style (MetaTheme *theme,
#if GTK_CHECK_VERSION(3, 0, 0)
GtkStyleContext *style_gtk,
- #else
- GtkStyle *style_gtk,
- #endif
- GtkWidget *widget,
- #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
#else
+ GtkWidget *widget,
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
@@ -1221,8 +1259,12 @@ MetaFrameType meta_frame_type_from_string (const char *s
const char* meta_frame_type_to_string (MetaFrameType type);
MetaGradientType meta_gradient_type_from_string (const char *str);
const char* meta_gradient_type_to_string (MetaGradientType type);
+#if GTK_CHECK_VERSION (3, 0, 0)
+GtkStateFlags meta_gtk_state_from_string (const char *str);
+#else
GtkStateType meta_gtk_state_from_string (const char *str);
const char* meta_gtk_state_to_string (GtkStateType state);
+#endif
GtkShadowType meta_gtk_shadow_from_string (const char *str);
const char* meta_gtk_shadow_to_string (GtkShadowType shadow);
GtkArrowType meta_gtk_arrow_from_string (const char *str);
diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c
index d5a68846..71b2e297 100644
--- a/src/ui/tile-preview.c
+++ b/src/ui/tile-preview.c
@@ -35,8 +35,12 @@
struct _MetaTilePreview {
GtkWidget *preview_window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *preview_color;
+#else
GdkColor *preview_color;
guchar preview_alpha;
+#endif
MetaRectangle tile_rect;
@@ -45,13 +49,14 @@ struct _MetaTilePreview {
static gboolean
#if GTK_CHECK_VERSION (3, 0, 0)
-meta_tile_preview_draw (GtkWidget *widget,
- cairo_t *cr,
+meta_tile_preview_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer user_data)
#else
meta_tile_preview_expose (GtkWidget *widget,
GdkEventExpose *event,
-#endif
gpointer user_data)
+#endif
{
MetaTilePreview *preview = user_data;
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -66,25 +71,42 @@ meta_tile_preview_expose (GtkWidget *widget,
if (preview->has_alpha)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA preview_color = *preview->preview_color;
+#endif
/* Fill the preview area with a transparent color */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &preview_color);
+#else
cairo_set_source_rgba (cr,
(double)preview->preview_color->red / 0xFFFF,
(double)preview->preview_color->green / 0xFFFF,
(double)preview->preview_color->blue / 0xFFFF,
(double)preview->preview_alpha / 0xFF);
+#endif
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
/* Use the opaque color for the border */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &preview_color);
+#else
gdk_cairo_set_source_color (cr, preview->preview_color);
+#endif
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA white = {1.0, 1.0, 1.0, 1.0};
+
+ gdk_cairo_set_source_rgba (cr, &white);
+#else
GtkStyle *style = gtk_widget_get_style (preview->preview_window);
gdk_cairo_set_source_color (cr, &style->white);
+#endif
cairo_rectangle (cr,
OUTLINE_WIDTH - 0.5, OUTLINE_WIDTH - 0.5,
@@ -112,6 +134,22 @@ on_preview_window_style_set (GtkWidget *widget,
gpointer user_data)
{
MetaTilePreview *preview = user_data;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *context = gtk_style_context_new ();
+ GtkWidgetPath *path = gtk_widget_path_new ();
+ guchar alpha = 0xFF;
+
+ gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
+ gtk_style_context_set_path (context, path);
+
+ gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED, "background-color", &preview->preview_color, NULL);
+ gtk_style_context_get_style (context, "selection-box-alpha", &alpha, NULL);
+
+ preview->preview_color->alpha = (double)alpha / 0xFF;
+
+ gtk_widget_path_free (path);
+ g_object_unref (context);
+#else
GtkStyle *style;
style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (widget),
@@ -135,6 +173,7 @@ on_preview_window_style_set (GtkWidget *widget,
}
g_object_unref (style);
+#endif
}
MetaTilePreview *
@@ -160,7 +199,9 @@ meta_tile_preview_new (int screen_number,
gtk_widget_set_app_paintable (preview->preview_window, TRUE);
preview->preview_color = NULL;
+#if !GTK_CHECK_VERSION (3, 0, 0)
preview->preview_alpha = 0xFF;
+#endif
preview->tile_rect.x = preview->tile_rect.y = 0;
preview->tile_rect.width = preview->tile_rect.height = 0;
@@ -207,7 +248,11 @@ meta_tile_preview_free (MetaTilePreview *preview)
gtk_widget_destroy (preview->preview_window);
if (preview->preview_color)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_rgba_free (preview->preview_color);
+#else
gdk_color_free (preview->preview_color);
+#endif
g_free (preview);
}
@@ -250,12 +295,20 @@ meta_tile_preview_show (MetaTilePreview *preview,
if (!preview->has_alpha)
{
- GdkRectangle outer_rect, inner_rect;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_rectangle_int_t outer_rect, inner_rect;
cairo_region_t *outer_region, *inner_region;
+ GdkRGBA black = {.0, .0, .0, 1.0};
+
+ gdk_window_set_background_rgba (window, &black);
+#else
+ GdkRectangle outer_rect, inner_rect;
+ GdkRegion *outer_region, *inner_region;
GdkColor black;
black = gtk_widget_get_style (preview->preview_window)->black;
gdk_window_set_background (window, &black);
+#endif
outer_rect.x = outer_rect.y = 0;
outer_rect.width = preview->tile_rect.width;
@@ -266,14 +319,25 @@ meta_tile_preview_show (MetaTilePreview *preview,
inner_rect.width = outer_rect.width - 2 * OUTLINE_WIDTH;
inner_rect.height = outer_rect.height - 2 * OUTLINE_WIDTH;
+#if GTK_CHECK_VERSION (3, 0, 0)
outer_region = cairo_region_create_rectangle (&outer_rect);
inner_region = cairo_region_create_rectangle (&inner_rect);
cairo_region_subtract (outer_region, inner_region);
cairo_region_destroy (inner_region);
- gdk_window_shape_combine_region (window, outer_region, 0, 0);
+ gtk_widget_shape_combine_region (preview->preview_window, outer_region);
cairo_region_destroy (outer_region);
+#else
+ outer_region = gdk_region_rectangle (&outer_rect);
+ inner_region = gdk_region_rectangle (&inner_rect);
+
+ gdk_region_subtract (outer_region, inner_region);
+ gdk_region_destroy (inner_region);
+
+ gdk_window_shape_combine_region (window, outer_region, 0, 0);
+ gdk_region_destroy (outer_region);
+#endif
}
}
diff --git a/src/ui/ui.c b/src/ui/ui.c
index b187f8cb..226e3c24 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -134,8 +134,8 @@ maybe_redirect_mouse_event (XEvent *xevent)
return FALSE;
#if GTK_CHECK_VERSION (3, 0, 0)
- gmanager = gdk_display_get_device_manager (gdisplay);
- gdevice = gdk_device_manager_get_client_pointer (gmanager);
+ gmanager = gdk_display_get_device_manager (gdisplay);
+ gdevice = gdk_device_manager_get_client_pointer (gmanager);
#endif
/* If GDK already thinks it has a grab, we better let it see events; this
@@ -256,6 +256,7 @@ maybe_redirect_mouse_event (XEvent *xevent)
/* If we've gotten here, we've filled in the gdk_event and should send it on */
#if GTK_CHECK_VERSION (3, 0, 0)
gdk_event_set_device (gevent, gdevice);
+ gtk_main_do_event (gevent);
gdk_event_free (gevent);
#else
gtk_main_do_event (&gevent);
@@ -978,7 +979,6 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
#endif
PangoContext *context;
const PangoFontDescription *font_desc;
- GtkStyle *default_style;
if (meta_ui_have_a_theme ())
{
@@ -1002,6 +1002,8 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
font_desc = (const PangoFontDescription *) free_font_desc;
#else
+ GtkStyle *default_style;
+
default_style = gtk_widget_get_default_style ();
font_desc = default_style->font_desc;
#endif
diff --git a/src/wm-tester/main.c b/src/wm-tester/main.c
index f970075f..d757270d 100644
--- a/src/wm-tester/main.c
+++ b/src/wm-tester/main.c
@@ -120,15 +120,19 @@ evil_timeout (gpointer data)
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- #if GTK_CHECK_VERSION(3, 0, 0)
- #define gtk_widget_set_uposition gtk_window_move
- #endif
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_window_move (GTK_WINDOW (w),
+ g_random_int_range (0,
+ gdk_screen_width ()),
+ g_random_int_range (0,
+ gdk_screen_height ()));
+#else
gtk_widget_set_uposition (w,
g_random_int_range (0,
gdk_screen_width ()),
g_random_int_range (0,
gdk_screen_height ()));
+#endif
parent = NULL;
@@ -205,6 +209,9 @@ set_up_icon_windows (void)
GtkWidget *c;
GList *icons;
GdkPixbuf *pix;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ int size = 0;
+#endif
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
c = gtk_button_new_with_label ("Icon window");
@@ -212,28 +219,43 @@ set_up_icon_windows (void)
icons = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, NULL, &size);
+ pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
+#else
pix = gtk_widget_render_icon (w,
GTK_STOCK_SAVE,
GTK_ICON_SIZE_LARGE_TOOLBAR,
NULL);
+#endif
icons = g_list_append (icons, pix);
if (i % 2)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, NULL, &size);
+ pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
+#else
pix = gtk_widget_render_icon (w,
GTK_STOCK_SAVE,
GTK_ICON_SIZE_DIALOG,
NULL);
+#endif
icons = g_list_append (icons, pix);
}
if (i % 3)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &size);
+ pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
+#else
pix = gtk_widget_render_icon (w,
GTK_STOCK_SAVE,
GTK_ICON_SIZE_MENU,
NULL);
+#endif
icons = g_list_append (icons, pix);
}