summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/fixedtip.c2
-rw-r--r--src/ui/frames.c28
-rw-r--r--src/ui/menu.c11
-rw-r--r--src/ui/metaaccellabel.c39
-rw-r--r--src/ui/preview-widget.c4
-rw-r--r--src/ui/tabpopup.c52
-rw-r--r--src/ui/theme-viewer.c138
-rw-r--r--src/ui/ui.c10
8 files changed, 161 insertions, 123 deletions
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 f5f0c7d4..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);
@@ -664,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
}
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 07a7c371..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);
@@ -500,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 e20bdeaa..da040ee8 100644
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
@@ -426,48 +426,57 @@ meta_accel_label_expose_event (GtkWidget *widget,
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_paint_layout (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
FALSE,
&event->area,
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index da8593d4..ea497e35 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -162,11 +162,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);
}
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);
+ &gtk_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/ui.c b/src/ui/ui.c
index 11a42e30..41273eaa 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -647,6 +647,7 @@ meta_image_window_set (MetaImageWindow *iw,
int x,
int y)
{
+ GdkWindow *window;
#if GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
#endif
@@ -673,16 +674,17 @@ meta_image_window_set (MetaImageWindow *iw,
cairo_destroy (cr);
#endif
- gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window),
+ window = gtk_widget_get_window (iw->window);
+ gdk_window_set_back_pixmap (window,
iw->pixmap,
FALSE);
- gdk_window_move_resize (gtk_widget_get_window (iw->window),
+ gdk_window_move_resize (window,
x, y,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
- gdk_window_clear (gtk_widget_get_window (iw->window));
+ gdk_window_clear (window);
}
#endif
@@ -714,7 +716,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;