diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/draw-workspace.c | 11 | ||||
-rw-r--r-- | src/ui/fixedtip.c | 2 | ||||
-rw-r--r-- | src/ui/frames.c | 32 | ||||
-rw-r--r-- | src/ui/menu.c | 29 | ||||
-rw-r--r-- | src/ui/metaaccellabel.c | 43 | ||||
-rw-r--r-- | src/ui/preview-widget.c | 19 | ||||
-rw-r--r-- | src/ui/tabpopup.c | 52 | ||||
-rw-r--r-- | src/ui/theme-viewer.c | 138 | ||||
-rw-r--r-- | src/ui/theme.c | 129 | ||||
-rw-r--r-- | src/ui/theme.h | 10 | ||||
-rw-r--r-- | src/ui/tile-preview.c | 25 | ||||
-rw-r--r-- | src/ui/ui.c | 193 |
12 files changed, 291 insertions, 392 deletions
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c index a40579db..4feb25c9 100644 --- a/src/ui/draw-workspace.c +++ b/src/ui/draw-workspace.c @@ -26,12 +26,7 @@ */ #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 - +#include "theme.h" static void get_window_rect (const WnckWindowDisplayInfo *win, @@ -110,7 +105,7 @@ draw_window (GtkWidget *widget, #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); + meta_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); @@ -268,7 +263,7 @@ wnck_draw_workspace (GtkWidget *widget, #if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; - mate_desktop_gtk_style_get_dark_color (style,state, &color); + meta_gtk_style_get_dark_color (style,state, &color); gdk_cairo_set_source_rgba (cr, &color); #else gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->dark[state]); diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c index fc1be2af..7037eab3 100644 --- a/src/ui/fixedtip.c +++ b/src/ui/fixedtip.c @@ -72,7 +72,7 @@ draw_handler (GtkWidget *tooltips, #else static gint -expose_handler (GtkTooltips *tooltips) +expose_handler (GtkTooltip *tooltips) { gtk_paint_flat_box (gtk_widget_get_style (tip), gtk_widget_get_window (tip), GTK_STATE_NORMAL, GTK_SHADOW_OUT, diff --git a/src/ui/frames.c b/src/ui/frames.c index 099c5052..99260936 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -161,6 +161,24 @@ meta_frames_get_type (void) #endif +static GObject * +meta_frames_constructor (GType gtype, + guint n_properties, + GObjectConstructParam *properties) +{ + GObject *object; + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (parent_class); + object = gobject_class->constructor (gtype, n_properties, properties); + + g_object_set (object, + "type", GTK_WINDOW_POPUP, + NULL); + + return object; +} + static void meta_frames_class_init (MetaFramesClass *class) { @@ -180,6 +198,7 @@ meta_frames_class_init (MetaFramesClass *class) parent_class = g_type_class_peek_parent (class); #endif + gobject_class->constructor = meta_frames_constructor; gobject_class->finalize = meta_frames_finalize; #if !GTK_CHECK_VERSION(3, 0, 0) object_class->destroy = meta_frames_destroy; @@ -245,10 +264,6 @@ prefs_changed_callback (MetaPreference pref, static void meta_frames_init (MetaFrames *frames) { - #if !GTK_CHECK_VERSION(3, 0, 0) - GTK_WINDOW (frames)->type = GTK_WINDOW_POPUP; - #endif - frames->text_heights = g_hash_table_new (NULL, NULL); frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal); @@ -565,6 +580,8 @@ meta_frames_ensure_layout (MetaFrames *frames, pango_layout_set_auto_dir (frame->layout, FALSE); + pango_layout_set_single_paragraph_mode (frame->layout, TRUE); + font_desc = meta_gtk_widget_get_font_desc (widget, scale, meta_prefs_get_titlebar_font ()); @@ -662,8 +679,9 @@ meta_frames_attach_style (MetaFrames *frames, frame->style = g_object_ref (gtk_widget_get_style_context (GTK_WIDGET (frames))); #else /* Weirdly, gtk_style_attach() steals a reference count from the style passed in */ - g_object_ref (GTK_WIDGET (frames)->style); - frame->style = gtk_style_attach (GTK_WIDGET (frames)->style, frame->window); + g_object_ref (gtk_widget_get_style (GTK_WIDGET (frames))); + frame->style = gtk_style_attach (gtk_widget_get_style (GTK_WIDGET (frames)), + frame->window); #endif } @@ -2324,7 +2342,7 @@ clip_to_screen (GdkRegion *region, MetaUIFrame *frame) META_CORE_GET_FRAME_Y, &frame_area.y, META_CORE_GET_FRAME_WIDTH, &frame_area.width, META_CORE_GET_FRAME_HEIGHT, &frame_area.height, - META_CORE_GET_SCREEN_WIDTH, &screen_area.height, + META_CORE_GET_SCREEN_WIDTH, &screen_area.width, META_CORE_GET_SCREEN_HEIGHT, &screen_area.height, META_CORE_GET_END); diff --git a/src/ui/menu.c b/src/ui/menu.c index 1dfc7140..407ef986 100644 --- a/src/ui/menu.c +++ b/src/ui/menu.c @@ -381,6 +381,7 @@ meta_window_menu_new (MetaFrames *frames, Display *display; Window xroot; GdkScreen *screen; + GdkWindow *window; GtkWidget *submenu; int j; @@ -393,7 +394,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)); + window = gtk_widget_get_window (GTK_WIDGET (frames)); display = GDK_WINDOW_XDISPLAY (window); @@ -440,20 +441,11 @@ meta_window_menu_new (MetaFrames *frames, "workspace", GINT_TO_POINTER (j)); - #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_data (G_OBJECT (submi), "activate", G_CALLBACK (activate_cb), md, (GClosureNotify) g_free, 0); - #else - gtk_signal_connect_full (GTK_OBJECT (submi), - "activate", - G_CALLBACK (activate_cb), - NULL, - md, - g_free, FALSE, FALSE); - #endif gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi); @@ -476,20 +468,11 @@ meta_window_menu_new (MetaFrames *frames, md->menu = menu; md->op = menuitem.op; - #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_data (G_OBJECT (mi), "activate", G_CALLBACK (activate_cb), md, (GClosureNotify) g_free, 0); - #else - gtk_signal_connect_full (GTK_OBJECT (mi), - "activate", - G_CALLBACK (activate_cb), - NULL, - md, - g_free, FALSE, FALSE); - #endif } if (mi) @@ -518,14 +501,8 @@ void meta_window_menu_popup(MetaWindowMenu* menu, int root_x, int root_y, int bu gtk_menu_popup(GTK_MENU (menu->menu), NULL, NULL, popup_position_func, pt, button, timestamp); - #if GTK_CHECK_VERSION(3, 0, 0) if (!gtk_widget_get_visible (menu->menu)) - #else - if (!GTK_MENU_SHELL(menu->menu)->have_xgrab) - #endif - { - meta_warning("GtkMenu failed to grab the pointer\n"); - } + meta_warning("GtkMenu failed to grab the pointer\n"); } void meta_window_menu_free(MetaWindowMenu* menu) diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c index 3ef870bc..da040ee8 100644 --- a/src/ui/metaaccellabel.c +++ b/src/ui/metaaccellabel.c @@ -423,52 +423,61 @@ meta_accel_label_expose_event (GtkWidget *widget, GtkMisc *misc = GTK_MISC (accel_label); PangoLayout *layout; - if (GTK_WIDGET_DRAWABLE (accel_label)) + if (gtk_widget_is_drawable (GTK_WIDGET (accel_label))) { int ac_width; + GtkAllocation allocation; + GtkRequisition requisition; + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_requisition (widget, &requisition); ac_width = meta_accel_label_get_accel_width (accel_label); - if (widget->allocation.width >= widget->requisition.width + ac_width) + if (allocation.width >= requisition.width + ac_width) { GtkTextDirection direction = gtk_widget_get_direction (widget); - gint x; - gint y; + gfloat xalign, yalign; + gint x, y; + gint xpad, ypad; + + gtk_misc_get_padding (misc, &xpad, &ypad); + gtk_misc_get_alignment (misc, &xalign, &yalign); if (direction == GTK_TEXT_DIR_RTL) { - widget->allocation.x += ac_width; + allocation.x += ac_width; } - widget->allocation.width -= ac_width; + allocation.width -= ac_width; + gtk_widget_set_allocation (widget, &allocation); if (GTK_WIDGET_CLASS (parent_class)->expose_event) GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); if (direction == GTK_TEXT_DIR_RTL) { - widget->allocation.x -= ac_width; + allocation.x -= ac_width; } - widget->allocation.width += ac_width; + allocation.width += ac_width; + gtk_widget_set_allocation (widget, &allocation); if (direction == GTK_TEXT_DIR_RTL) { - x = widget->allocation.x + misc->xpad; + x = allocation.x + allocation.width - xpad - ac_width; } else { - x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width; + x = allocation.x + allocation.width - xpad - ac_width; } - y = (widget->allocation.y * (1.0 - misc->yalign) + - (widget->allocation.y + widget->allocation.height - - (widget->requisition.height - misc->ypad * 2)) * - misc->yalign) + 1.5; + y = (allocation.y * (1.0 - yalign) + + (allocation.y + allocation.height - + (requisition.height - ypad * 2)) * yalign) + 1.5; layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string); - gtk_paint_layout (widget->style, - widget->window, - GTK_WIDGET_STATE (widget), + gtk_paint_layout (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget), FALSE, &event->area, widget, diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c index da8593d4..9138c6f5 100644 --- a/src/ui/preview-widget.c +++ b/src/ui/preview-widget.c @@ -103,19 +103,17 @@ meta_preview_class_init (MetaPreviewClass *class) gobject_class->finalize = meta_preview_finalize; - #if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 0, 0) widget_class->draw = meta_preview_draw; widget_class->get_preferred_width = meta_preview_get_preferred_width; widget_class->get_preferred_height = meta_preview_get_preferred_height; - #else - widget_class->expose_event = meta_preview_expose; - widget_class->size_request = meta_preview_size_request; - #endif - widget_class->size_allocate = meta_preview_size_allocate; -#if GTK_CHECK_VERSION(3, 0, 0) gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (class)); +#else + widget_class->expose_event = meta_preview_expose; + widget_class->size_request = meta_preview_size_request; #endif + widget_class->size_allocate = meta_preview_size_allocate; } static void @@ -162,11 +160,7 @@ meta_preview_new (void) { MetaPreview *preview; - #if GTK_CHECK_VERSION(3, 0, 0) preview = g_object_new (META_TYPE_PREVIEW, NULL); - #else - preview = gtk_type_new (META_TYPE_PREVIEW); - #endif return GTK_WIDGET (preview); } @@ -447,9 +441,6 @@ meta_preview_expose (GtkWidget *widget, return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); } -#endif - -#if !GTK_CHECK_VERSION (3, 0, 0) static void meta_preview_size_request (GtkWidget *widget, GtkRequisition *req) diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c index dfbdf1a4..12fb4250 100644 --- a/src/ui/tabpopup.c +++ b/src/ui/tabpopup.c @@ -535,16 +535,16 @@ display_entry (MetaTabPopup *popup, if (popup->outline) { + window = gtk_widget_get_window (popup->outline_window); + /* Do stuff behind gtk's back */ - gdk_window_hide (gtk_widget_get_window(popup->outline_window)); + gdk_window_hide (window); meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); rect = te->rect; rect.x = 0; rect.y = 0; - window = gtk_widget_get_window(GTK_WIDGET(popup->outline_window)); - gdk_window_move_resize (window, te->rect.x, te->rect.y, te->rect.width, te->rect.height); @@ -554,7 +554,7 @@ display_entry (MetaTabPopup *popup, gdk_window_set_background_rgba (window, &black); #else gdk_window_set_background (window, - &popup->outline_window->style->black); + >k_widget_get_style (popup->outline_window)->black); #endif region = gdk_region_rectangle (&rect); @@ -828,35 +828,41 @@ meta_select_image_expose_event (GtkWidget *widget, { if (META_SELECT_IMAGE (widget)->selected) { - int x, y, w, h; + GtkAllocation allocation; + GtkRequisition requisition; GtkMisc *misc; GtkStyle *style; GtkStateType state; + GdkWindow *window; + int x, y, w, h; + int xpad, ypad; + float xalign, yalign; cairo_t *cr; - GtkAllocation allocation; - - gtk_widget_get_allocation(widget, &allocation); misc = GTK_MISC (widget); - x = (allocation.x * (1.0 - misc->xalign) + + gtk_widget_get_allocation(widget, &allocation); + gtk_widget_get_requisition (widget, &requisition); + gtk_misc_get_padding (misc, &xpad, &ypad); + gtk_misc_get_alignment (misc, &xalign, &yalign); + + x = (allocation.x * (1.0 - xalign) + (allocation.x + allocation.width - - (widget->requisition.width - misc->xpad * 2)) * - misc->xalign) + 0.5; - y = (allocation.y * (1.0 - misc->yalign) + + - (requisition.width - xpad * 2)) * xalign) + 0.5; + y = (allocation.y * (1.0 - yalign) + (allocation.y + allocation.height - - (widget->requisition.height - misc->ypad * 2)) * - misc->yalign) + 0.5; + - (requisition.height - ypad * 2)) * yalign) + 0.5; x -= INSIDE_SELECT_RECT + 1; y -= INSIDE_SELECT_RECT + 1; - w = widget->requisition.width - OUTSIDE_SELECT_RECT * 2 - 1; - h = widget->requisition.height - OUTSIDE_SELECT_RECT * 2 - 1; + w = requisition.width - OUTSIDE_SELECT_RECT * 2 - 1; + h = requisition.height - OUTSIDE_SELECT_RECT * 2 - 1; + window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); state = gtk_widget_get_state (widget); - cr = gdk_cairo_create (gtk_widget_get_window(widget)); + cr = gdk_cairo_create (window); cairo_set_line_width (cr, 2.0); gdk_cairo_set_source_color (cr, &style->fg[state]); @@ -1127,13 +1133,12 @@ meta_select_workspace_expose_event (GtkWidget *widget, { MetaWorkspace *workspace; WnckWindowDisplayInfo *windows; + GtkAllocation allocation; GtkStyle *style; + GdkWindow *window; cairo_t *cr; int i, n_windows; GList *tmp, *list; - GtkAllocation allocation; - - gtk_widget_get_allocation(widget, &allocation); workspace = META_SELECT_WORKSPACE (widget)->workspace; @@ -1170,8 +1175,11 @@ meta_select_workspace_expose_event (GtkWidget *widget, g_list_free (list); + window = gtk_widget_get_window (widget); + gtk_widget_get_allocation (widget, &allocation); + wnck_draw_workspace (widget, - gtk_widget_get_window(widget), + window, SELECT_OUTLINE_WIDTH, SELECT_OUTLINE_WIDTH, allocation.width - SELECT_OUTLINE_WIDTH * 2, @@ -1188,7 +1196,7 @@ meta_select_workspace_expose_event (GtkWidget *widget, if (META_SELECT_WORKSPACE (widget)->selected) { style = gtk_widget_get_style (widget); - cr = gdk_cairo_create (gtk_widget_get_window(widget)); + cr = gdk_cairo_create (window); gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]); diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c index 0a5e4eb2..a9ef8103 100644 --- a/src/ui/theme-viewer.c +++ b/src/ui/theme-viewer.c @@ -76,92 +76,99 @@ static void run_position_expression_timings (void); static void run_theme_benchmark (void); -static GtkItemFactoryEntry menu_items[] = +static const gchar *menu_item_string = + "<ui>\n" + "<menubar>\n" + "<menu name='Windows' action='Windows'>\n" + "<menuitem name='Dialog' action='Dialog'/>\n" + "<menuitem name='Modal dialog' action='Modal dialog'/>\n" + "<menuitem name='Utility' action='Utility'/>\n" + "<menuitem name='Splashscreen' action='Splashscreen'/>\n" + "<menuitem name='Top dock' action='Top dock'/>\n" + "<menuitem name='Bottom dock' action='Bottom dock'/>\n" + "<menuitem name='Left dock' action='Left dock'/>\n" + "<menuitem name='Right dock' action='Right dock'/>\n" + "<menuitem name='Desktop' action='Desktop'/>\n" + "</menu>\n" + "</menubar>\n" + "<toolbar>\n" + "<separator/>\n" + "<toolitem name='New' action='New'/>\n" + "<toolitem name='Open' action='Open'/>\n" + "<toolitem name='Quit' action='Quit'/>\n" + "<separator/>\n" + "</toolbar>\n" + "</ui>\n"; + +static GtkActionEntry menu_items[] = { - { N_("/_Windows"), NULL, NULL, 0, "<Branch>" }, - { N_("/Windows/tearoff"), NULL, NULL, 0, "<Tearoff>" }, - { N_("/Windows/_Dialog"), "<control>d", NULL, 0, NULL }, - { N_("/Windows/_Modal dialog"), NULL, NULL, 0, NULL }, - { N_("/Windows/_Utility"), "<control>u", NULL, 0, NULL }, - { N_("/Windows/_Splashscreen"), "<control>s", NULL, 0, NULL }, - { N_("/Windows/_Top dock"), NULL, NULL, 0, NULL }, - { N_("/Windows/_Bottom dock"), NULL, NULL, 0, NULL }, - { N_("/Windows/_Left dock"), NULL, NULL, 0, NULL }, - { N_("/Windows/_Right dock"), NULL, NULL, 0, NULL }, - { N_("/Windows/_All docks"), NULL, NULL, 0, NULL }, - { N_("/Windows/Des_ktop"), NULL, NULL, 0, NULL } + { "Windows", NULL, N_("_Windows"), NULL, NULL, NULL }, + { "Dialog", NULL, N_("_Dialog"), "<control>d", NULL, NULL }, + { "Modal dialog", NULL, N_("_Modal dialog"), NULL, NULL, NULL }, + { "Utility", NULL, N_("_Utility"), "<control>u", NULL, NULL }, + { "Splashscreen", NULL, N_("_Splashscreen"), "<control>s", NULL, NULL }, + { "Top dock", NULL, N_("_Top dock"), NULL, NULL, NULL }, + { "Bottom dock", NULL, N_("_Bottom dock"), NULL, NULL, NULL }, + { "Left dock", NULL, N_("_Left dock"), NULL, NULL, NULL }, + { "Right dock", NULL, N_("_Right dock"), NULL, NULL, NULL }, + { "All docks", NULL, N_("_All docks"), NULL, NULL, NULL }, + { "Desktop", NULL, N_("Des_ktop"), NULL, NULL, NULL } +}; + +static GtkActionEntry tool_items[] = +{ + { "New", GTK_STOCK_NEW, NULL, NULL, + N_("Open another one of these windows"), NULL }, + { "Open", GTK_STOCK_OPEN, NULL, NULL, + N_("This is a demo button with an 'open' icon"), NULL }, + { "Quit", GTK_STOCK_QUIT, NULL, NULL, + N_("This is a demo button with a 'quit' icon"), NULL } }; static GtkWidget * normal_contents (void) { GtkWidget *table; - GtkWidget *toolbar; GtkWidget *handlebox; GtkWidget *statusbar; GtkWidget *contents; GtkWidget *sw; - GtkItemFactory *item_factory; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; table = gtk_table_new (1, 4, FALSE); /* Create the menubar */ - item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL); + action_group = gtk_action_group_new ("mainmenu"); + gtk_action_group_add_actions (action_group, + menu_items, + G_N_ELEMENTS (menu_items), + NULL); + gtk_action_group_add_actions (action_group, + tool_items, + G_N_ELEMENTS (tool_items), + NULL); - gtk_item_factory_set_translate_func(item_factory, - (GtkTranslateFunc)gettext, NULL, NULL); + ui_manager = gtk_ui_manager_new (); - /* Set up item factory to go away */ - g_object_ref (item_factory); - g_object_ref_sink (item_factory); - g_object_unref (item_factory); - g_object_set_data_full (G_OBJECT (table), - "<main>", - item_factory, - (GDestroyNotify) g_object_unref); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* create menu items */ - gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items), - menu_items, NULL); + gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL); gtk_table_attach (GTK_TABLE (table), - gtk_item_factory_get_widget (item_factory, "<main>"), + gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"), /* X direction */ /* Y direction */ 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); - /* Create the toolbar - */ - toolbar = gtk_toolbar_new (); - - GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW); - gtk_tool_item_set_tooltip_text(newButton, - "Open another one of these windows"); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - newButton, - -1); /*-1 means append to end of toolbar*/ - - GtkToolItem *openButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN); - gtk_tool_item_set_tooltip_text(openButton, - "This is a demo button with an \'open\' icon"); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - openButton, - -1); /*-1 means append to end of toolbar*/ - - GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); - gtk_tool_item_set_tooltip_text(quitButton, - "This is a demo button with a \'quit\' icon"); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - quitButton, - -1); /*-1 means append to end of toolbar*/ - - handlebox = gtk_handle_box_new (); - gtk_container_add (GTK_CONTAINER (handlebox), toolbar); + gtk_container_add (GTK_CONTAINER (handlebox), + gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar")); gtk_table_attach (GTK_TABLE (table), handlebox, @@ -208,6 +215,8 @@ normal_contents (void) gtk_widget_show_all (table); + g_object_unref (ui_manager); + return table; } @@ -778,6 +787,7 @@ main (int argc, char **argv) { GtkWidget *window; GtkWidget *collection; + GtkStyle *style; GError *err; clock_t start, end; GtkWidget *notebook; @@ -852,26 +862,28 @@ main (int argc, char **argv) G_CALLBACK (gtk_main_quit), NULL); gtk_widget_realize (window); - g_assert (window->style); - g_assert (window->style->font_desc); + style = gtk_widget_get_style (window); + + g_assert (style); + g_assert (style->font_desc); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); collection = preview_collection (FONT_SIZE_NORMAL, - window->style->font_desc); + style->font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Normal Title Font"))); collection = preview_collection (FONT_SIZE_SMALL, - window->style->font_desc); + style->font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Small Title Font"))); collection = preview_collection (FONT_SIZE_LARGE, - window->style->font_desc); + style->font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Large Title Font"))); @@ -922,7 +934,7 @@ get_flags (GtkWidget *widget) static int get_text_height (GtkWidget *widget) { - return meta_pango_font_desc_get_text_height (widget->style->font_desc, + return meta_pango_font_desc_get_text_height (gtk_widget_get_style (widget)->font_desc, gtk_widget_get_pango_context (widget)); } @@ -1003,7 +1015,7 @@ run_theme_benchmark (void) /* Creating the pixmap in the loop is right, since * GDK does the same with its double buffering. */ - pixmap = gdk_pixmap_new (widget->window, + pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), client_width + left_width + right_width, client_height + top_height + bottom_height, -1); diff --git a/src/ui/theme.c b/src/ui/theme.c index a7dc8d08..c9f2ab47 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -64,11 +64,6 @@ #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) | \ @@ -1312,7 +1307,6 @@ meta_color_spec_new_from_string (const char *str, spec = meta_color_spec_new (META_COLOR_SPEC_GTK); spec->data.gtk.state = state; spec->data.gtk.component = component; - g_assert (spec->data.gtk.state < N_GTK_STATES); g_assert (spec->data.gtk.component < META_GTK_COLOR_LAST); } else if (str[0] == 'b' && str[1] == 'l' && str[2] == 'e' && str[3] == 'n' && @@ -1488,6 +1482,72 @@ meta_color_spec_new_gtk (MetaGtkColorComponent component, #if GTK_CHECK_VERSION (3, 0, 0) static void +get_background_color_real (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GdkRGBA *c; + + g_return_if_fail (color != NULL); + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + gtk_style_context_get (context, + state, + "background-color", &c, + NULL); + + *color = *c; + gdk_rgba_free (c); +} + +static void +get_background_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GdkRGBA empty = { 0.0, 0.0, 0.0, 0.0 }; + GdkRGBA rgba; + + get_background_color_real (context, state, &rgba); + + if (gdk_rgba_equal (&rgba, &empty)) + { + GtkWidget *toplevel; + GtkStyleContext *tmp; + + toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL); + tmp = gtk_widget_get_style_context (toplevel); + + get_background_color_real (tmp, state, &rgba); + + gtk_widget_destroy (toplevel); + } + + *color = rgba; +} + +/* Based on set_color() in gtkstyle.c */ +#define LIGHTNESS_MULT 1.3 +#define DARKNESS_MULT 0.7 +void +meta_gtk_style_get_light_color (GtkStyleContext *style, + GtkStateFlags state, + GdkRGBA *color) +{ + get_background_color (style, state, color); + gtk_style_shade (color, color, LIGHTNESS_MULT); +} + +void +meta_gtk_style_get_dark_color (GtkStyleContext *style, + GtkStateFlags state, + GdkRGBA *color) +{ + get_background_color (style, state, color); + gtk_style_shade (color, color, DARKNESS_MULT); +} + +static void meta_set_color_from_style (GdkRGBA *color, GtkStyleContext *context, GtkStateFlags state, @@ -1499,7 +1559,7 @@ meta_set_color_from_style (GdkRGBA *color, { case META_GTK_COLOR_BG: case META_GTK_COLOR_BASE: - gtk_style_context_get_background_color (context, state, color); + get_background_color (context, state, color); break; case META_GTK_COLOR_FG: case META_GTK_COLOR_TEXT: @@ -1514,18 +1574,18 @@ meta_set_color_from_style (GdkRGBA *color, 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); + meta_gtk_style_get_light_color (context, state, color); + meta_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); + meta_gtk_style_get_light_color (context, state, color); break; case META_GTK_COLOR_DARK: - mate_desktop_gtk_style_get_dark_color (context, state, color); + meta_gtk_style_get_dark_color (context, state, color); break; case META_GTK_COLOR_LAST: g_assert_not_reached (); @@ -3698,44 +3758,31 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op, y2 = y1; /* This is one of the cases where we are matching the exact - * pixel aligned rectangle produced by X. + * pixel aligned rectangle produced by X; for zero-width lines + * the generic algorithm produces the right result so we don't + * need to handle them here. */ - if (y1 == y2 || x1 == x2) + if ((y1 == y2 || x1 == x2) && op->data.line.width != 0) { - double offset = (op->data.line.width == 0 || - op->data.line.width % 2) ? .5 : 0; - /* X includes end points for lines of width 0 */ - double line_extend = op->data.line.width == 0 ? 1. : 0.; + double offset = op->data.line.width % 2 ? .5 : 0; if (y1 == y2) { - if (x2 < x1) - { - x1 ^= x2; - x2 ^= x1; - x1 ^= x2; - } cairo_move_to (cr, x1, y1 + offset); - cairo_line_to (cr, x2 + line_extend, y2 + offset); + cairo_line_to (cr, x2, y2 + offset); } else { - if (y2 < y1) - { - y1 ^= y2; - y2 ^= y1; - y1 ^= y2; - } cairo_move_to (cr, x1 + offset, y1); - cairo_line_to (cr, x2 + offset, y2 + line_extend); + cairo_line_to (cr, x2 + offset, y2); } } else { - if (op->data.line.width <= 0) - { - cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - } + /* zero-width lines include both end-points in X, unlike wide lines */ + if (op->data.line.width == 0) + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); + cairo_move_to (cr, x1 + .5, y1 + .5); cairo_line_to (cr, x2 + .5, y2 + .5); } @@ -4745,10 +4792,10 @@ meta_frame_style_validate (MetaFrameStyle *style, } static void -button_rect (MetaButtonType type, - const MetaFrameGeometry *fgeom, - int middle_background_offset, - GdkRectangle *rect) +get_button_rect (MetaButtonType type, + const MetaFrameGeometry *fgeom, + int middle_background_offset, + GdkRectangle *rect) { switch (type) { @@ -5068,7 +5115,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style, { MetaButtonState button_state; - button_rect (j, fgeom, middle_bg_offset, &rect); + get_button_rect (j, fgeom, middle_bg_offset, &rect); button_state = map_button_state (j, fgeom, middle_bg_offset, button_states); op_list = get_button (style, j, button_state); @@ -5123,7 +5170,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style, { MetaButtonState button_state; - button_rect (j, fgeom, middle_bg_offset, &rect); + get_button_rect (j, fgeom, middle_bg_offset, &rect); rect.x += x_offset; rect.y += y_offset; diff --git a/src/ui/theme.h b/src/ui/theme.h index 66996d89..ea3ec196 100644 --- a/src/ui/theme.h +++ b/src/ui/theme.h @@ -694,8 +694,6 @@ typedef enum META_FRAME_PIECE_LAST } MetaFramePiece; -#define N_GTK_STATES 5 - /** * How to draw a frame in a particular state (say, a focussed, non-maximised, * resizable frame). This corresponds closely to the <frame_style> tag @@ -1271,6 +1269,14 @@ GtkArrowType meta_gtk_arrow_from_string (const char *s const char* meta_gtk_arrow_to_string (GtkArrowType arrow); MetaImageFillType meta_image_fill_type_from_string (const char *str); const char* meta_image_fill_type_to_string (MetaImageFillType fill_type); +#if GTK_CHECK_VERSION (3, 0, 0) +void meta_gtk_style_get_light_color (GtkStyleContext *style, + GtkStateFlags state, + GdkRGBA *color); +void meta_gtk_style_get_dark_color (GtkStyleContext *style, + GtkStateFlags state, + GdkRGBA *color); +#endif guint meta_theme_earliest_version_with_button (MetaButtonType type); diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c index c938317b..e14ffe25 100644 --- a/src/ui/tile-preview.c +++ b/src/ui/tile-preview.c @@ -62,24 +62,16 @@ meta_tile_preview_expose (GtkWidget *widget, { MetaTilePreview *preview = user_data; #if !GTK_CHECK_VERSION (3, 0, 0) - GdkWindow *window; - cairo_t *cr; - - window = gtk_widget_get_window (widget); - cr = gdk_cairo_create (window); + cairo_t *cr = gdk_cairo_create (event->window); #endif cairo_set_line_width (cr, 1.0); 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); + gdk_cairo_set_source_rgba (cr, preview->preview_color); #else cairo_set_source_rgba (cr, (double)preview->preview_color->red / 0xFFFF, @@ -93,7 +85,7 @@ meta_tile_preview_expose (GtkWidget *widget, /* Use the opaque color for the border */ #if GTK_CHECK_VERSION (3, 0, 0) - gdk_cairo_set_source_rgba (cr, &preview_color); + gdk_cairo_set_source_rgba (cr, preview->preview_color); #else gdk_cairo_set_source_color (cr, preview->preview_color); #endif @@ -121,6 +113,13 @@ meta_tile_preview_expose (GtkWidget *widget, 0.5, 0.5, preview->tile_rect.width - 1, preview->tile_rect.height - 1); + +#if GTK_CHECK_VERSION (3, 0, 0) + if (preview->has_alpha) { + cairo_fill_preserve (cr); + cairo_set_source_rgba (cr, preview->preview_color->red, preview->preview_color->green, preview->preview_color->blue, 1.0); + } +#endif cairo_stroke (cr); #if !GTK_CHECK_VERSION (3, 0, 0) @@ -265,11 +264,7 @@ meta_tile_preview_show (MetaTilePreview *preview, return; /* nothing to do */ window = gtk_widget_get_window (preview->preview_window); -#if GTK_CHECK_VERSION (3, 0, 0) meta_core_lower_beneath_focus_window (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), -#else - meta_core_lower_beneath_focus_window (gdk_display, -#endif GDK_WINDOW_XID (window), gtk_get_current_event_time ()); diff --git a/src/ui/ui.c b/src/ui/ui.c index bbef9395..76ef72fa 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -58,7 +58,7 @@ void meta_ui_init(int* argc, char*** argv) * GDK will no longer generate the core XEvents we process. * So at least for now, enforce the previous behavior. */ -#if GTK_CHECK_VERSION(2, 91, 7) +#if GTK_CHECK_VERSION(3, 0, 0) gdk_disable_multidevice (); #endif @@ -125,11 +125,7 @@ maybe_redirect_mouse_event (XEvent *xevent) if (!ui) return FALSE; -#if GTK_CHECK_VERSION (3, 0, 0) gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window); -#else - gdk_window = gdk_window_lookup_for_display (gdisplay, window); -#endif if (gdk_window == NULL) return FALSE; @@ -584,109 +580,6 @@ meta_ui_window_menu_free (MetaWindowMenu *menu) } #if !GTK_CHECK_VERSION (3, 0, 0) -struct _MetaImageWindow -{ - GtkWidget *window; - GdkPixmap *pixmap; -}; - -MetaImageWindow* -meta_image_window_new (Display *xdisplay, - int screen_number, - int max_width, - int max_height) -{ - MetaImageWindow *iw; - GdkDisplay *gdisplay; - GdkScreen *gscreen; - - iw = g_new (MetaImageWindow, 1); - iw->window = gtk_window_new (GTK_WINDOW_POPUP); - - gdisplay = gdk_x11_lookup_xdisplay (xdisplay); - gscreen = gdk_display_get_screen (gdisplay, screen_number); - - gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen); - - gtk_widget_realize (iw->window); - iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window), - max_width, max_height, - -1); - - gtk_widget_set_size_request (iw->window, 1, 1); - gtk_widget_set_double_buffered (iw->window, FALSE); - gtk_widget_set_app_paintable (iw->window, TRUE); - - return iw; -} - -void -meta_image_window_free (MetaImageWindow *iw) -{ - gtk_widget_destroy (iw->window); - g_object_unref (G_OBJECT (iw->pixmap)); - g_free (iw); -} - -void -meta_image_window_set_showing (MetaImageWindow *iw, - gboolean showing) -{ - if (showing) - gtk_widget_show_all (iw->window); - else - { - gtk_widget_hide (iw->window); - meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); - } -} - -void -meta_image_window_set (MetaImageWindow *iw, - GdkPixbuf *pixbuf, - int x, - int y) -{ -#if GTK_CHECK_VERSION (3, 0, 0) - cairo_t *cr; -#endif - - /* We use a back pixmap to avoid having to handle exposes, because - * it's really too slow for large clients being minimized, etc. - * and this way flicker is genuinely zero. - */ - -#if !GTK_CHECK_VERSION (3, 0, 0) - gdk_draw_pixbuf (iw->pixmap, - gtk_widget_get_style (iw->window)->black_gc, - pixbuf, - 0, 0, - 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, - 0, 0); -#else - cr = gdk_cairo_create (iw->pixmap); - gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); -#endif - - gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window), - iw->pixmap, - FALSE); - - gdk_window_move_resize (gtk_widget_get_window (iw->window), - x, y, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf)); - - gdk_window_clear (gtk_widget_get_window (iw->window)); -} -#endif - -#if !GTK_CHECK_VERSION (3, 0, 0) static GdkColormap* get_cmap (GdkPixmap *pixmap) { @@ -714,7 +607,7 @@ get_cmap (GdkPixmap *pixmap) /* Be sure we aren't going to blow up due to visual mismatch */ if (cmap && - (gdk_colormap_get_visual (cmap)->depth != + (gdk_visual_get_depth (gdk_colormap_get_visual (cmap)) != gdk_drawable_get_depth (pixmap))) { cmap = NULL; @@ -791,14 +684,10 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest, { GdkDrawable *drawable; GdkPixbuf *retval; -#if !GTK_CHECK_VERSION (3, 0, 0) GdkColormap *cmap; -#endif retval = NULL; -#if !GTK_CHECK_VERSION (3, 0, 0) cmap = NULL; -#endif drawable = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xpixmap); @@ -818,10 +707,8 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest, dest_x, dest_y, width, height); } -#if !GTK_CHECK_VERSION (3, 0, 0) if (cmap) g_object_unref (G_OBJECT (cmap)); -#endif if (drawable) g_object_unref (G_OBJECT (drawable)); @@ -841,6 +728,20 @@ meta_ui_pop_delay_exposes (MetaUI *ui) meta_frames_pop_delay_exposes (ui->frames); } +static GdkPixbuf * +load_default_window_icon (int size) +{ + GtkIconTheme *theme = gtk_icon_theme_get_default (); + const char *icon_name; + + if (gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME)) + icon_name = META_DEFAULT_ICON_NAME; + else + icon_name = "image-missing"; + + return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL); +} + GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui) { @@ -848,26 +749,7 @@ meta_ui_get_default_window_icon (MetaUI *ui) if (default_icon == NULL) { - GtkIconTheme *theme; - gboolean icon_exists; - - theme = gtk_icon_theme_get_default (); - - icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME); - - if (icon_exists) - default_icon = gtk_icon_theme_load_icon (theme, - META_DEFAULT_ICON_NAME, - META_ICON_WIDTH, - 0, - NULL); - else - default_icon = gtk_icon_theme_load_icon (theme, - "image-missing", - META_ICON_WIDTH, - 0, - NULL); - + default_icon = load_default_window_icon (META_ICON_WIDTH); g_assert (default_icon); } @@ -931,38 +813,6 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay, return FALSE; } -char* -meta_text_property_to_utf8 (Display *xdisplay, - const XTextProperty *prop) -{ - GdkDisplay *display; - char **list; - int count; - char *retval; - - list = NULL; - - display = gdk_x11_lookup_xdisplay (xdisplay); - count = gdk_text_property_to_utf8_list_for_display (display, - gdk_x11_xatom_to_atom_for_display (display, prop->encoding), - prop->format, - prop->value, - prop->nitems, - &list); - - if (count == 0) - retval = NULL; - else - { - retval = list[0]; - list[0] = g_strdup (""); /* something to free */ - } - - g_strfreev (list); - - return retval; -} - void meta_ui_theme_get_frame_borders (MetaUI *ui, MetaFrameType type, @@ -1253,9 +1103,7 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap) GdkPixmap* gpmap; GdkScreen* screen; GdkPixbuf* pixbuf; -#if !GTK_CHECK_VERSION (3, 0, 0) GdkColormap* cmap; -#endif int width; int height; int depth; @@ -1263,16 +1111,10 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap) gpmap = gdk_pixmap_foreign_new(pmap); screen = gdk_drawable_get_screen(gpmap); -#if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(GDK_WINDOW(gpmap)); - height = gdk_window_get_height(GDK_WINDOW(gpmap)); -#else gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height); -#endif depth = gdk_drawable_get_depth(GDK_DRAWABLE(gpmap)); -#if !GTK_CHECK_VERSION (3, 0, 0) if (depth <= 24) { cmap = gdk_screen_get_system_colormap(screen); @@ -1281,7 +1123,6 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap) { cmap = gdk_screen_get_rgba_colormap(screen); } -#endif pixbuf = gdk_pixbuf_get_from_drawable(NULL, gpmap, cmap, 0, 0, 0, 0, width, height); |