summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinfirit <[email protected]>2015-09-14 19:07:06 +0200
committerinfirit <[email protected]>2015-09-14 19:07:06 +0200
commitb04c37a7641b474ca066627da27d42e6134c4e17 (patch)
treed607c2e5858d2354a13480f9352a4f49f8353195 /src
parent768fdd8d3852e67555a585da28b6404a97853cbd (diff)
downloadmarco-b04c37a7641b474ca066627da27d42e6134c4e17.tar.bz2
marco-b04c37a7641b474ca066627da27d42e6134c4e17.tar.xz
Remove deprecated GTK+ symbols and use accessor functions
Direct struct access has been deprecated, so use the appropriate replacements to build with GSEAL enabled.
Diffstat (limited to 'src')
-rw-r--r--src/tools/marco-window-demo.c344
-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
9 files changed, 339 insertions, 289 deletions
diff --git a/src/tools/marco-window-demo.c b/src/tools/marco-window-demo.c
index 1585b385..edff5f71 100644
--- a/src/tools/marco-window-demo.c
+++ b/src/tools/marco-window-demo.c
@@ -74,19 +74,22 @@ static void
on_realize_set_struts (GtkWindow *window,
gpointer data)
{
+ GtkWidget *widget;
int left;
int right;
int top;
int bottom;
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
+ widget = GTK_WIDGET (window);
+
+ g_return_if_fail (gtk_widget_get_realized (widget));
left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-left"));
right = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-right"));
top = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-top"));
bottom = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-bottom"));
- set_gdk_window_struts (gtk_widget_get_window (GTK_WIDGET (window)),
+ set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@@ -97,6 +100,10 @@ set_gtk_window_struts (GtkWidget *window,
int top,
int bottom)
{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_object_set_data (G_OBJECT (window), "meta-strut-left",
GINT_TO_POINTER (left));
g_object_set_data (G_OBJECT (window), "meta-strut-right",
@@ -115,8 +122,8 @@ set_gtk_window_struts (GtkWidget *window,
G_CALLBACK (on_realize_set_struts),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_struts (gtk_widget_get_window (GTK_WIDGET (window)),
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@@ -157,6 +164,10 @@ static void
set_gtk_window_type (GtkWindow *window,
const char *type)
{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_object_set_data (G_OBJECT (window), "meta-window-type", (char*) type);
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
@@ -168,8 +179,8 @@ set_gtk_window_type (GtkWindow *window,
G_CALLBACK (on_realize_set_type),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_type (gtk_widget_get_window (GTK_WIDGET (window)),
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
@@ -183,14 +194,22 @@ static void
on_realize_set_border_only (GtkWindow *window,
gpointer data)
{
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
- set_gdk_window_border_only (gtk_widget_get_window (GTK_WIDGET (window)));
+ g_return_if_fail (gtk_widget_get_realized (widget));
+
+ set_gdk_window_border_only (gtk_widget_get_window (widget));
}
static void
set_gtk_window_border_only (GtkWindow *window)
{
+GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
on_realize_set_border_only,
NULL);
@@ -200,8 +219,8 @@ set_gtk_window_border_only (GtkWindow *window)
G_CALLBACK (on_realize_set_border_only),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_border_only (gtk_widget_get_window (GTK_WIDGET (window)));
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_border_only (gtk_widget_get_window (widget));
}
int
@@ -307,9 +326,8 @@ dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
make_dialog (GTK_WIDGET (callback_data), 1);
@@ -322,9 +340,8 @@ modal_dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-modal_dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+modal_dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *dialog;
@@ -349,9 +366,8 @@ no_parent_dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-no_parent_dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+no_parent_dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
make_dialog (NULL, 1);
@@ -364,9 +380,8 @@ utility_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-utility_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+utility_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -405,9 +420,8 @@ toolbar_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-toolbar_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+toolbar_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -437,9 +451,8 @@ menu_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-menu_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+menu_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -469,9 +482,8 @@ override_redirect_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-override_redirect_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+override_redirect_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -498,9 +510,8 @@ border_only_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-border_only_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+border_only_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -575,9 +586,8 @@ splashscreen_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-splashscreen_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+splashscreen_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -691,15 +701,14 @@ dock_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-dock_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+dock_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
-#if GTK_CHECK_VERSION (3, 0, 0)
guint callback_action;
const gchar *name;
+#if GTK_CHECK_VERSION (3, 0, 0)
g_object_get (G_OBJECT (action), "name", &name, NULL);
if (!g_strcmp0 (name, "top-dock"))
@@ -714,6 +723,21 @@ dock_cb (gpointer callback_data,
callback_action = DOCK_ALL;
else
return;
+#else
+ name = gtk_action_get_name (action);
+
+ 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)
{
@@ -735,9 +759,8 @@ desktop_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-desktop_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+desktop_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -777,30 +800,6 @@ desktop_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
-#if !GTK_CHECK_VERSION(3, 0, 0)
-static GtkItemFactoryEntry menu_items[] =
-{
- { "/_Windows", NULL, NULL, 0, "<Branch>" },
- { "/Windows/tearoff", NULL, NULL, 0, "<Tearoff>" },
- { "/Windows/_Dialog", "<control>d", dialog_cb, 0, NULL },
- { "/Windows/_Modal dialog", NULL, modal_dialog_cb, 0, NULL },
- { "/Windows/_Parentless dialog", NULL, no_parent_dialog_cb, 0, NULL },
- { "/Windows/_Utility", "<control>u", utility_cb, 0, NULL },
- { "/Windows/_Splashscreen", "<control>s", splashscreen_cb, 0, NULL },
- { "/Windows/_Top dock", NULL, dock_cb, DOCK_TOP, NULL },
- { "/Windows/_Bottom dock", NULL, dock_cb, DOCK_BOTTOM, NULL },
- { "/Windows/_Left dock", NULL, dock_cb, DOCK_LEFT, NULL },
- { "/Windows/_Right dock", NULL, dock_cb, DOCK_RIGHT, NULL },
- { "/Windows/_All docks", NULL, dock_cb, DOCK_ALL, NULL },
- { "/Windows/Des_ktop", NULL, desktop_cb, 0, NULL },
- { "/Windows/Me_nu", NULL, menu_cb, 0, NULL },
- { "/Windows/Tool_bar", NULL, toolbar_cb, 0, NULL },
- { "/Windows/Override Redirect", NULL, override_redirect_cb, 0, NULL },
- { "/Windows/Border Only", NULL, border_only_cb, 0, NULL }
-};
-
-#endif
-
#if GTK_CHECK_VERSION (3, 0, 0)
static void
sleep_cb (GSimpleAction *action,
@@ -808,7 +807,7 @@ sleep_cb (GSimpleAction *action,
gpointer data)
#else
static void
-sleep_cb (GtkWidget *button,
+sleep_cb (GtkAction *action,
gpointer data)
#endif
{
@@ -822,12 +821,13 @@ toggle_aspect_ratio (GSimpleAction *action,
gpointer data)
#else
static void
-toggle_aspect_ratio (GtkWidget *button,
+toggle_aspect_ratio (GtkAction *action,
gpointer data)
#endif
{
GtkWidget *window;
GdkGeometry geom;
+ GtkWidget *widget = GTK_WIDGET (data);
if (aspect_on)
{
@@ -842,11 +842,7 @@ 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
+ window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
if (window)
gtk_window_set_geometry_hints (GTK_WINDOW (window),
GTK_WIDGET (data),
@@ -867,11 +863,7 @@ toggle_decorated_cb (GtkWidget *button,
#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)));
@@ -1088,6 +1080,90 @@ create_toolbar (void)
return toolbar;
}
+#else
+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='Parentless dialog' action='Parentless 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='All docks' action='All docks'/>\n"
+ "<menuitem name='Desktop' action='Desktop'/>\n"
+ "<menuitem name='Menu' action='Menu'/>\n"
+ "<menuitem name='Toolbar' action='Toolbar'/>\n"
+ "<menuitem name='Override Redirect' action='Override Redirect'/>\n"
+ "<menuitem name='Border Only' action='Border Only'/>\n"
+ "</menu>\n"
+ "</menubar>\n"
+ "<toolbar>\n"
+ "<toolitem name='New' action='New'/>\n"
+ "<toolitem name='Lock' action='Lock'/>\n"
+ "<toolitem name='Decorations' action='Decorations'/>\n"
+ "<toolitem name='Ratio' action='Ratio'/>\n"
+ "<toolitem name='Quit' action='Quit'/>\n"
+ "</toolbar>\n"
+ "</ui>\n";
+
+static const GtkActionEntry menu_items[] =
+{
+ { "Windows", NULL, "_Windows", NULL,
+ NULL, NULL },
+ { "Dialog", NULL, "_Dialog", "<control>d",
+ NULL, G_CALLBACK (dialog_cb) },
+ { "Modal dialog", NULL, "_Modal dialog", NULL,
+ NULL, G_CALLBACK (modal_dialog_cb) },
+ { "Parentless dialog", NULL, "_Parentless dialog", NULL,
+ NULL, G_CALLBACK (no_parent_dialog_cb) },
+ { "Utility", NULL, "_Utility", "<control>u",
+ NULL, G_CALLBACK (utility_cb) },
+ { "Splashscreen", NULL, "_Splashscreen", "<control>s",
+ NULL, G_CALLBACK (splashscreen_cb) },
+ { "Top dock", NULL, "_Top dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Bottom dock", NULL, "_Bottom dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Left dock", NULL, "_Left dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Right dock", NULL, "_Right dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "All docks", NULL, "_All docks", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Desktop", NULL, "Des_ktop", NULL,
+ NULL, G_CALLBACK (desktop_cb) },
+ { "Menu", NULL, "Me_nu", NULL,
+ NULL, G_CALLBACK (menu_cb) },
+ { "Toolbar", NULL, "Tool_bar", NULL,
+ NULL, G_CALLBACK (toolbar_cb) },
+ { "Override Redirect", NULL, "Override Redirect", NULL,
+ NULL, G_CALLBACK (override_redirect_cb) },
+ { "Border Only", NULL, "Border Only", NULL,
+ NULL, G_CALLBACK (border_only_cb) }
+};
+
+static const GtkActionEntry tool_items[] =
+{
+ { "New", GTK_STOCK_NEW, NULL, NULL,
+ "Open another one of these windows", G_CALLBACK (do_appwindow) },
+ { "Lock", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that"
+ " locks up the demo", G_CALLBACK (sleep_cb) },
+ { "Decorations", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that "
+ "toggles window decorations", G_CALLBACK (toggle_decorated_cb) },
+ { "Quit", GTK_STOCK_QUIT, NULL, NULL,
+ "This is a demo button with "
+ " a 'quit' icon", G_CALLBACK (clicked_toolbar_cb) },
+ { "Ratio", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that locks the aspect ratio "
+ "using a hint", G_CALLBACK (toggle_aspect_ratio) }
+};
#endif
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -1103,27 +1179,20 @@ do_appwindow (void)
GtkWidget *window;
#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *grid;
+ GtkWidget *toolbar;
+ GSimpleActionGroup *action_group;
+ GtkBuilder *builder;
#else
GtkWidget *table;
-#endif
- GtkWidget *toolbar;
-#if !GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *handlebox;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
#endif
GtkWidget *statusbar;
GtkWidget *contents;
GtkWidget *sw;
GtkTextBuffer *buffer;
- #if GTK_CHECK_VERSION(3, 0, 0)
- GSimpleActionGroup *action_group;
- GtkBuilder *builder;
- #else
- GtkAccelGroup *accel_group;
- GtkItemFactory *item_factory;
- #endif
-
-
/* Create the toplevel window
*/
@@ -1179,27 +1248,27 @@ do_appwindow (void)
/* Create the menubar
*/
- accel_group = gtk_accel_group_new ();
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
- g_object_unref (accel_group);
+ contents = gtk_text_view_new ();
+
+ action_group = gtk_action_group_new ("mainmenu");
+ gtk_action_group_add_actions (action_group,
+ menu_items,
+ G_N_ELEMENTS (menu_items),
+ window);
+ gtk_action_group_add_actions (action_group,
+ tool_items,
+ G_N_ELEMENTS (tool_items),
+ window);
- item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
+ ui_manager = gtk_ui_manager_new ();
- /* Set up item factory to go away with the window */
- g_object_ref (item_factory);
- g_object_ref_sink (item_factory);
- g_object_unref (item_factory);
- g_object_set_data_full (G_OBJECT (window),
- "<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, window);
+ 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,
@@ -1237,7 +1306,6 @@ do_appwindow (void)
gtk_window_set_default_size (GTK_WINDOW (window),
200, 200);
- contents = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
PANGO_WRAP_WORD);
@@ -1247,68 +1315,11 @@ do_appwindow (void)
#if !GTK_CHECK_VERSION (3, 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");
- g_signal_connect(G_OBJECT(newButton),
- "clicked",
- G_CALLBACK(do_appwindow),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- newButton,
- -1); /*-1 means append to end of toolbar*/
-
-
- GtkToolItem *lockButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(lockButton,
- "This is a demo button that locks up the demo");
- g_signal_connect(G_OBJECT(lockButton),
- "clicked",
- G_CALLBACK(sleep_cb),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- lockButton,
- -1); /*-1 means append to end of toolbar*/
-
-
- GtkToolItem *decoButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(decoButton,
- "This is a demo button that toggles window decorations");
- g_signal_connect(G_OBJECT(decoButton),
- "clicked",
- G_CALLBACK(toggle_decorated_cb),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- decoButton,
- -1); /*-1 means append to end of toolbar*/
-
- GtkToolItem *lockRatioButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(lockRatioButton,
- "This is a demo button that locks the aspect ratio using a hint");
- g_signal_connect(G_OBJECT(lockRatioButton),
- "clicked",
- G_CALLBACK(toggle_aspect_ratio),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- lockRatioButton,
- -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");
- g_signal_connect(G_OBJECT(quitButton),
- "clicked",
- G_CALLBACK(clicked_toolbar_cb),
- window);
- 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,
@@ -1362,6 +1373,7 @@ do_appwindow (void)
g_object_unref (action_group);
g_object_unref (builder);
#else
+ g_object_unref (ui_manager);
return window;
#endif
}
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;