[metacity] Remove deprecated GTK+ symbols



commit aa7c16103ad0d1199790e4e5fdae97af020e5260
Author: Florian MÃllner <fmuellner gnome org>
Date:   Tue May 24 19:46:50 2011 +0200

    Remove deprecated GTK+ symbols
    
    Based on an original patch from Roberto Guido <bob4mail gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=572332

 src/tools/metacity-window-demo.c |  344 +++++++++++++++++++++-----------------
 src/ui/fixedtip.c                |    2 +-
 src/ui/frames.c                  |   27 +---
 src/ui/menu.c                    |   32 ++--
 src/ui/metaaccellabel.c          |   30 +---
 src/ui/preview-widget.c          |   27 +---
 src/ui/resizepopup.c             |    4 +-
 src/ui/tabpopup.c                |    4 +-
 src/ui/theme-viewer.c            |  123 ++++++++-------
 src/ui/themewidget.c             |   33 +----
 src/wm-tester/main.c             |   10 +-
 11 files changed, 294 insertions(+), 342 deletions(-)
---
diff --git a/src/tools/metacity-window-demo.c b/src/tools/metacity-window-demo.c
index 03b5d9a..dce370f 100644
--- a/src/tools/metacity-window-demo.c
+++ b/src/tools/metacity-window-demo.c
@@ -51,7 +51,7 @@ set_gdk_window_struts (GdkWindow *window,
   vals[11] = 800;
 
   XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                   GDK_WINDOW_XWINDOW (window),
+                   GDK_WINDOW_XID (window),
                    XInternAtom (GDK_WINDOW_XDISPLAY (window),
                                 "_NET_WM_STRUT_PARTIAL", False),
                    XA_CARDINAL, 32, PropModeReplace,
@@ -62,19 +62,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);
 }
 
@@ -85,6 +88,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",
@@ -103,8 +110,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);
 }
 
@@ -118,7 +125,7 @@ set_gdk_window_type (GdkWindow  *window,
                           type, False);
   
   XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                   GDK_WINDOW_XWINDOW (window),
+                   GDK_WINDOW_XID (window),
                    XInternAtom (GDK_WINDOW_XDISPLAY (window), "_NET_WM_WINDOW_TYPE", False),
                    XA_ATOM, 32, PropModeReplace,
                    (guchar *)atoms, 
@@ -129,15 +136,18 @@ static void
 on_realize_set_type (GtkWindow *window,
                      gpointer   data)
 {
+  GtkWidget *widget;
   const char *type;
 
-  g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
+  widget = GTK_WIDGET (window);
+
+  g_return_if_fail (gtk_widget_get_realized (widget));
 
   type = g_object_get_data (G_OBJECT (window), "meta-window-type");
 
   g_return_if_fail (type != NULL);
   
-  set_gdk_window_type (gtk_widget_get_window (GTK_WIDGET (window)),
+  set_gdk_window_type (gtk_widget_get_window (widget),
                        type);
 }
 
@@ -145,6 +155,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),
@@ -156,8 +170,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);
 }
 
@@ -171,14 +185,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);
+
+  g_return_if_fail (gtk_widget_get_realized (widget));
   
-  set_gdk_window_border_only (gtk_widget_get_window (GTK_WIDGET (window)));
+  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);
@@ -188,8 +210,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
@@ -285,17 +307,15 @@ response_cb (GtkDialog *dialog,
 }
 
 static void
-dialog_cb (gpointer             callback_data,
-           guint                callback_action,
-           GtkWidget           *widget)
+dialog_cb (GtkAction *action,
+           gpointer   callback_data)
 {
   make_dialog (GTK_WIDGET (callback_data), 1);
 }
 
 static void
-modal_dialog_cb (gpointer             callback_data,
-                 guint                callback_action,
-                 GtkWidget           *widget)
+modal_dialog_cb (GtkAction *action,
+                 gpointer   callback_data)
 {
   GtkWidget *dialog;
   
@@ -313,17 +333,15 @@ modal_dialog_cb (gpointer             callback_data,
 }
 
 static void
-no_parent_dialog_cb (gpointer             callback_data,
-                     guint                callback_action,
-                     GtkWidget           *widget)
+no_parent_dialog_cb (GtkAction *action,
+                     gpointer   callback_data)
 {
   make_dialog (NULL, 1);
 }
 
 static void
-utility_cb (gpointer             callback_data,
-            guint                callback_action,
-            GtkWidget           *widget)
+utility_cb (GtkAction *action,
+            gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -355,9 +373,8 @@ utility_cb (gpointer             callback_data,
 }
 
 static void
-toolbar_cb (gpointer             callback_data,
-            guint                callback_action,
-            GtkWidget           *widget)
+toolbar_cb (GtkAction *action,
+            gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -380,9 +397,8 @@ toolbar_cb (gpointer             callback_data,
 }
 
 static void
-menu_cb (gpointer             callback_data,
-         guint                callback_action,
-         GtkWidget           *widget)
+menu_cb (GtkAction *action,
+         gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -405,9 +421,8 @@ menu_cb (gpointer             callback_data,
 }
 
 static void
-override_redirect_cb (gpointer             callback_data,
-                      guint                callback_action,
-                      GtkWidget           *widget)
+override_redirect_cb (GtkAction *action,
+                      gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -427,9 +442,8 @@ override_redirect_cb (gpointer             callback_data,
 }
 
 static void
-border_only_cb (gpointer             callback_data,
-                guint                callback_action,
-                GtkWidget           *widget)
+border_only_cb (GtkAction *action,
+                gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -453,9 +467,8 @@ border_only_cb (gpointer             callback_data,
 
 #if 0
 static void
-changing_icon_cb (gpointer             callback_data,
-                  guint                callback_action,
-                  GtkWidget           *widget)
+changing_icon_cb (GtkAction *action,
+                  gpointer             callback_data)
 {
   GtkWidget *window;
   GtkWidget *vbox;
@@ -521,9 +534,8 @@ focus_label (GtkWidget *window)
 }
 
 static void
-splashscreen_cb (gpointer             callback_data,
-                 guint                callback_action,
-                 GtkWidget           *widget)
+splashscreen_cb (GtkAction *action,
+                 gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *image;
@@ -630,10 +642,27 @@ make_dock (int type)
 }
 
 static void
-dock_cb (gpointer             callback_data,
-         guint                callback_action,
-         GtkWidget           *widget)
+dock_cb (GtkAction *action,
+         gpointer   callback_data)
 {
+  guint callback_action;
+  const gchar *name;
+
+  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;
+
   if (callback_action == DOCK_ALL)
     {
       make_dock (DOCK_TOP);
@@ -648,9 +677,8 @@ dock_cb (gpointer             callback_data,
 }
 
 static void
-desktop_cb (gpointer             callback_data,
-            guint                callback_action,
-            GtkWidget           *widget)
+desktop_cb (GtkAction *action,
+            gpointer   callback_data)
 {
   GtkWidget *window;
   GtkWidget *label;
@@ -676,40 +704,20 @@ desktop_cb (gpointer             callback_data,
   gtk_widget_show_all (window);
 }
 
-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 }
-};
-
 static void
-sleep_cb (GtkWidget *button,
+sleep_cb (GtkAction *action,
           gpointer   data)
 {
   sleep (1000);
 }
 
 static void
-toggle_aspect_ratio (GtkWidget *button,
+toggle_aspect_ratio (GtkAction *action,
                      gpointer   data)
 {
   GtkWidget *window;
   GdkGeometry geom;
+  GtkWidget *widget = GTK_WIDGET (data);
 
   if (aspect_on)
     {
@@ -724,7 +732,7 @@ toggle_aspect_ratio (GtkWidget *button,
 
   aspect_on = !aspect_on;
 
-  window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
+  window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
   if (window)
     gtk_window_set_geometry_hints (GTK_WINDOW (window),
 				   GTK_WIDGET (data),
@@ -738,7 +746,7 @@ toggle_decorated_cb (GtkWidget *button,
                      gpointer   data)
 {
   GtkWidget *window;
-  window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
+  window = gtk_widget_get_ancestor (data, GTK_TYPE_WINDOW);
   if (window)
     gtk_window_set_decorated (GTK_WINDOW (window),
                               !gtk_window_get_decorated (GTK_WINDOW (window)));
@@ -812,19 +820,102 @@ destroy_cb (GtkWidget *w, gpointer data)
     gtk_main_quit ();
 }
 
+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) }
+};
+
 static GtkWidget *
 do_appwindow (void)
 {
   GtkWidget *window;
   GtkWidget *table;
-  GtkWidget *toolbar;
   GtkWidget *handlebox;
   GtkWidget *statusbar;
   GtkWidget *contents;
   GtkWidget *sw;
   GtkTextBuffer *buffer;
-  GtkAccelGroup *accel_group;      
-  GtkItemFactory *item_factory;
+  GtkActionGroup *action_group;
+  GtkUIManager *ui_manager;
 
       
   /* Create the toplevel window
@@ -847,27 +938,28 @@ 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);
-      
-  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 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);
 
-  /* 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);
+  ui_manager = gtk_ui_manager_new ();
+
+  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,
@@ -895,7 +987,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);
       
@@ -904,68 +995,11 @@ do_appwindow (void)
 
   /* 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,
@@ -1010,6 +1044,8 @@ do_appwindow (void)
 
   gtk_widget_show_all (window);
 
+  g_object_unref (ui_manager);
+
   return window;
 }
 
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index be25390..2776f2c 100644
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
@@ -51,7 +51,7 @@ static int screen_right_edge = 0;
 static int screen_bottom_edge = 0;
 
 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 22f501e..65dfcf8 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -108,30 +108,7 @@ static void invalidate_whole_window (MetaFrames *frames,
 
 static GtkWidgetClass *parent_class = NULL;
 
-GType
-meta_frames_get_type (void)
-{
-  static GType frames_type = 0;
-
-  if (!frames_type)
-    {
-      static const GtkTypeInfo frames_info =
-      {
-        "MetaFrames",
-        sizeof (MetaFrames),
-        sizeof (MetaFramesClass),
-        (GtkClassInitFunc) meta_frames_class_init,
-        (GtkObjectInitFunc) meta_frames_init,
-        /* reserved_1 */ NULL,
-        /* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
-      };
-
-      frames_type = gtk_type_unique (GTK_TYPE_WINDOW, &frames_info);
-    }
-
-  return frames_type;
-}
+G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_WINDOW);
 
 static void
 meta_frames_class_init (MetaFramesClass *class)
@@ -460,7 +437,7 @@ meta_frames_ensure_layout (MetaFrames  *frames,
   MetaFrameType type;
   MetaFrameStyle *style;
   
-  g_return_if_fail (GTK_WIDGET_REALIZED (frames));
+  g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (frames)));
 
   widget = GTK_WIDGET (frames);
       
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 7060733..9e23feb 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -139,7 +139,8 @@ menu_closed (GtkMenu *widget,
   menu = data;
 
   meta_frames_notify_menu_hide (menu->frames);
-  (* menu->func) (menu, GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+  (* menu->func) (menu,
+                  GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                   menu->client_xwindow,
                   gtk_get_current_event_time (),
                   0, 0,
@@ -158,7 +159,8 @@ activate_cb (GtkWidget *menuitem, gpointer data)
   md = data;
 
   meta_frames_notify_menu_hide (md->menu->frames);
-  (* md->menu->func) (md->menu, GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+  (* md->menu->func) (md->menu,
+                      GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                       md->menu->client_xwindow,
                       gtk_get_current_event_time (),
                       md->op,
@@ -386,6 +388,7 @@ meta_window_menu_new   (MetaFrames         *frames,
                   Display *display;
                   Window xroot;
                   GdkScreen *screen;
+                  GdkWindow *window;
                   GtkWidget *submenu;
                   int j;
 
@@ -398,10 +401,11 @@ meta_window_menu_new   (MetaFrames         *frames,
                   meta_verbose ("Creating %d-workspace menu current space %lu\n",
                       n_workspaces, active_workspace);
 
-                  display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
+                  window = gtk_widget_get_window (GTK_WIDGET (frames));
+                  display = GDK_WINDOW_XDISPLAY (window);
 
-                  screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
-                  xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
+                  screen = gdk_window_get_screen (window);
+                  xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
 
                   submenu = gtk_menu_new ();
 
@@ -443,12 +447,11 @@ meta_window_menu_new   (MetaFrames         *frames,
                           "workspace",
                           GINT_TO_POINTER (j));
 
-                      gtk_signal_connect_full (GTK_OBJECT (submi),
+                      g_signal_connect_data (G_OBJECT (submi),
                           "activate",
                           G_CALLBACK (activate_cb),
-                          NULL,
                           md,
-                          g_free, FALSE, FALSE);
+                          (GClosureNotify) g_free, 0);
 
                       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi);
 
@@ -471,12 +474,11 @@ meta_window_menu_new   (MetaFrames         *frames,
               md->menu = menu;
               md->op = menuitem.op;
               
-              gtk_signal_connect_full (GTK_OBJECT (mi),
-                                       "activate",
-                                       G_CALLBACK (activate_cb),
-                                       NULL,
-                                       md,
-                                       g_free, FALSE, FALSE);
+              g_signal_connect_data (G_OBJECT (mi),
+                                     "activate",
+                                     G_CALLBACK (activate_cb),
+                                     md,
+                                     (GClosureNotify) g_free, 0);
             }
 
           if (mi)
@@ -520,7 +522,7 @@ meta_window_menu_popup (MetaWindowMenu     *menu,
                   button,
                   timestamp);
 
-  if (!GTK_MENU_SHELL (menu->menu)->have_xgrab)
+  if (!gtk_widget_get_visible (menu->menu))
     meta_warning ("GtkMenu failed to grab the pointer\n");
 }
 
diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c
index f4f06ac..6b02fc4 100644
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
@@ -52,31 +52,7 @@ static int   meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
 
 static GtkLabelClass *parent_class = NULL;
 
-
-GType
-meta_accel_label_get_type (void)
-{
-  static GType accel_label_type = 0;
-
-  if (!accel_label_type)
-    {
-      static const GtkTypeInfo accel_label_info =
-      {
-	"MetaAccelLabel",
-	sizeof (MetaAccelLabel),
-	sizeof (MetaAccelLabelClass),
-	(GtkClassInitFunc) meta_accel_label_class_init,
-	(GtkObjectInitFunc) meta_accel_label_init,
-        /* reserved_1 */ NULL,
-	/* reserved_2 */ NULL,
-	(GtkClassInitFunc) NULL,
-      };
-
-      accel_label_type = gtk_type_unique (GTK_TYPE_LABEL, &accel_label_info);
-    }
-
-  return accel_label_type;
-}
+G_DEFINE_TYPE (MetaAccelLabel, meta_accel_label, GTK_TYPE_LABEL);
 
 static void
 meta_accel_label_class_init (MetaAccelLabelClass *class)
@@ -262,7 +238,7 @@ 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;
 
@@ -307,7 +283,7 @@ meta_accel_label_expose_event (GtkWidget      *widget,
 
           gtk_paint_layout (widget->style,
                             widget->window,
-                            GTK_WIDGET_STATE (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 26b2756..422d9a6 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -40,30 +40,7 @@ static void     meta_preview_finalize      (GObject          *object);
 
 static GtkWidgetClass *parent_class;
 
-GType
-meta_preview_get_type (void)
-{
-  static GType preview_type = 0;
-
-  if (!preview_type)
-    {
-      static const GtkTypeInfo preview_info =
-      {
-	"MetaPreview",
-	sizeof (MetaPreview),
-	sizeof (MetaPreviewClass),
-	(GtkClassInitFunc) meta_preview_class_init,
-	(GtkObjectInitFunc) meta_preview_init,
-	/* reserved_1 */ NULL,
-        /* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
-      };
-
-      preview_type = gtk_type_unique (GTK_TYPE_BIN, &preview_info);
-    }
-
-  return preview_type;
-}
+G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
 
 static void
 meta_preview_class_init (MetaPreviewClass *class)
@@ -125,7 +102,7 @@ meta_preview_new (void)
 {
   MetaPreview *preview;
   
-  preview = gtk_type_new (META_TYPE_PREVIEW);
+  preview = g_object_new (META_TYPE_PREVIEW, NULL);
   
   return GTK_WIDGET (preview);
 }
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index 11698e8..3b200c0 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -123,7 +123,7 @@ update_size_window (MetaResizePopup *popup)
   x = popup->rect.x + (popup->rect.width - width) / 2;
   y = popup->rect.y + (popup->rect.height - height) / 2;
   
-  if (GTK_WIDGET_REALIZED (popup->size_window))
+  if (gtk_widget_get_realized (popup->size_window))
     {
       /* using move_resize to avoid jumpiness */
       gdk_window_move_resize (popup->size_window->window,
@@ -145,7 +145,7 @@ sync_showing (MetaResizePopup *popup)
       if (popup->size_window)
         gtk_widget_show (popup->size_window);
       
-      if (popup->size_window && GTK_WIDGET_REALIZED (popup->size_window))
+      if (popup->size_window && gtk_widget_get_realized (popup->size_window))
         gdk_window_raise (popup->size_window->window);
     }
   else
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index 544bb01..0d2ed89 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -442,7 +442,7 @@ meta_ui_tab_popup_set_showing (MetaTabPopup *popup,
     }
   else
     {
-      if (GTK_WIDGET_VISIBLE (popup->window))
+      if (gtk_widget_get_visible (popup->window))
         {
           meta_verbose ("Hiding tab popup window\n");
           gtk_widget_hide (popup->window);
@@ -508,7 +508,7 @@ display_entry (MetaTabPopup *popup,
        * we manually set the window as mapped and then manually map it
        * with gdk functions.
        */
-      GTK_WIDGET_SET_FLAGS (popup->outline_window, GTK_MAPPED);
+      gtk_widget_set_mapped (popup->outline_window, TRUE);
       gdk_window_show_unraised (popup->outline_window->window);
     }
 
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index b1fd496..7067d59 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -70,92 +70,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);
 
-  gtk_item_factory_set_translate_func(item_factory,
-				      (GtkTranslateFunc)gettext, NULL, 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);
+
+  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,
@@ -202,6 +209,8 @@ normal_contents (void)
 
   gtk_widget_show_all (table);
 
+  g_object_unref (ui_manager);
+
   return table;
 }
 
diff --git a/src/ui/themewidget.c b/src/ui/themewidget.c
index 7ee9db0..1af0518 100644
--- a/src/ui/themewidget.c
+++ b/src/ui/themewidget.c
@@ -35,39 +35,14 @@ static void meta_area_finalize     (GObject        *object);
 
 static GtkMiscClass *parent_class;
 
-GType
-meta_area_get_type (void)
-{
-  static GType area_type = 0;
-
-  if (!area_type)
-    {
-      static const GtkTypeInfo area_info =
-      {
-	"MetaArea",
-	sizeof (MetaArea),
-	sizeof (MetaAreaClass),
-	(GtkClassInitFunc) meta_area_class_init,
-	(GtkObjectInitFunc) meta_area_init,
-	/* reserved_1 */ NULL,
-        /* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
-      };
-
-      area_type = gtk_type_unique (GTK_TYPE_MISC, &area_info);
-    }
-
-  return area_type;
-}
+G_DEFINE_TYPE (MetaArea, meta_area, GTK_TYPE_MISC);
 
 static void
 meta_area_class_init (MetaAreaClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
-  GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
 
-  object_class = (GtkObjectClass*) class;
   widget_class = (GtkWidgetClass*) class;
   parent_class = g_type_class_peek (gtk_misc_get_type ());
 
@@ -80,7 +55,7 @@ meta_area_class_init (MetaAreaClass *class)
 static void
 meta_area_init (MetaArea *area)
 {
-  GTK_WIDGET_SET_FLAGS (area, GTK_NO_WINDOW);
+  gtk_widget_set_has_window (GTK_WIDGET (area), FALSE);
 }
 
 GtkWidget*
@@ -88,7 +63,7 @@ meta_area_new (void)
 {
   MetaArea *area;
   
-  area = gtk_type_new (META_TYPE_AREA);
+  area = g_object_new (META_TYPE_AREA, NULL);
   
   return GTK_WIDGET (area);
 }
@@ -118,7 +93,7 @@ meta_area_expose (GtkWidget      *widget,
   g_return_val_if_fail (META_IS_AREA (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       area = META_AREA (widget);
       misc = GTK_MISC (widget);
diff --git a/src/wm-tester/main.c b/src/wm-tester/main.c
index e56d660..d9b27b4 100644
--- a/src/wm-tester/main.c
+++ b/src/wm-tester/main.c
@@ -120,11 +120,11 @@ evil_timeout (gpointer data)
       
       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
-      gtk_widget_set_uposition (w,
-                                g_random_int_range (0,
-                                                    gdk_screen_width ()),
-                                g_random_int_range (0,
-                                                    gdk_screen_height ()));
+      gtk_window_move (GTK_WINDOW (w),
+                       g_random_int_range (0,
+                                           gdk_screen_width ()),
+                       g_random_int_range (0,
+                                           gdk_screen_height ()));
 
       parent = NULL;
       



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]