From b04c37a7641b474ca066627da27d42e6134c4e17 Mon Sep 17 00:00:00 2001 From: infirit Date: Mon, 14 Sep 2015 19:07:06 +0200 Subject: Remove deprecated GTK+ symbols and use accessor functions Direct struct access has been deprecated, so use the appropriate replacements to build with GSEAL enabled. --- src/ui/theme-viewer.c | 138 +++++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 63 deletions(-) (limited to 'src/ui/theme-viewer.c') 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 = + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; + +static GtkActionEntry menu_items[] = { - { N_("/_Windows"), NULL, NULL, 0, "" }, - { N_("/Windows/tearoff"), NULL, NULL, 0, "" }, - { N_("/Windows/_Dialog"), "d", NULL, 0, NULL }, - { N_("/Windows/_Modal dialog"), NULL, NULL, 0, NULL }, - { N_("/Windows/_Utility"), "u", NULL, 0, NULL }, - { N_("/Windows/_Splashscreen"), "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"), "d", NULL, NULL }, + { "Modal dialog", NULL, N_("_Modal dialog"), NULL, NULL, NULL }, + { "Utility", NULL, N_("_Utility"), "u", NULL, NULL }, + { "Splashscreen", NULL, N_("_Splashscreen"), "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, "
", 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), - "
", - 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, "
"), + 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); -- cgit v1.2.1