[dia] Porting from GtkTooltips to GtkTooltip



commit 7ed13e8b7e7a116e441cb00e5044c0d60e4d488a
Author: Hans Breuer <hans breuer org>
Date:   Sun May 24 14:26:19 2009 +0200

    Porting from GtkTooltips to GtkTooltip
    
    http://library.gnome.org/devel/gtk/stable/gtk-migrating-tooltips.html
---
 app/filedlg.c         |    7 -----
 app/interface.c       |   59 +++++++++++++++++-------------------------------
 app/interface.h       |    4 ---
 app/layer_dialog.c    |    3 +-
 app/menus.c           |   10 +++-----
 lib/diaarrowchooser.c |   12 +++------
 lib/diaarrowchooser.h |    8 +-----
 7 files changed, 31 insertions(+), 72 deletions(-)

diff --git a/app/filedlg.c b/app/filedlg.c
index 3c7ed24..1c68ba1 100644
--- a/app/filedlg.c
+++ b/app/filedlg.c
@@ -452,17 +452,10 @@ file_save_as_callback(gpointer data, guint action, GtkWidget *widget)
     g_signal_connect(G_OBJECT(compressbutton), "toggled",
 		     G_CALLBACK(toggle_compress_callback), NULL);
     gtk_widget_show(compressbutton);
-#if GTK_CHECK_VERSION (2,12,0)
     gtk_widget_set_tooltip_text (compressbutton,
 			 _("Compression reduces file size to less than 1/10th "
 			   "size and speeds up loading and saving.  Some text "
 			   "programs cannot manipulate compressed files."));
-#else
-    gtk_tooltips_set_tip(tool_tips, compressbutton,
-			 _("Compression reduces file size to less than 1/10th "
-			   "size and speeds up loading and saving.  Some text "
-			   "programs cannot manipulate compressed files."), NULL);
-#endif
     g_signal_connect (GTK_FILE_CHOOSER(savedlg),
 		      "response", G_CALLBACK(file_save_as_response_callback), compressbutton);
     g_signal_connect(GTK_OBJECT(savedlg), "destroy",
diff --git a/app/interface.c b/app/interface.c
index 2b0fbd9..81966f3 100644
--- a/app/interface.c
+++ b/app/interface.c
@@ -22,7 +22,6 @@
 #undef GTK_DISABLE_DEPRECATED /* gnome */
 #include <gnome.h>
 #else
-#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
 #include <gtk/gtk.h>
 #endif
 #include "gtkwrapbox.h"
@@ -267,7 +266,6 @@ static struct
     GtkWidget    * layer_view;
 } ui;
 
-/*static*/ GtkTooltips *tool_tips;
 static GSList *tool_group = NULL;
 
 GtkWidget *modify_tool_button;
@@ -617,8 +615,8 @@ use_integrated_ui_for_display_shell(DDisplay *ddisp, char *title)
 
   /*  Popup button between scrollbars for navigation window  */
   navigation_button = navigation_popup_new(ddisp);
-  gtk_tooltips_set_tip(tool_tips, navigation_button,
-                       _("Pops up the Navigation window."), NULL);
+  gtk_widget_set_tooltip_text(navigation_button,
+                       _("Pops up the Navigation window."));
   gtk_widget_show(navigation_button);
 
   /*  Canvas  */
@@ -726,9 +724,6 @@ create_display_shell(DDisplay *ddisp,
   ddisp->container            = NULL;
 
 
-  if (!tool_tips) /* needed here if we dont create_toolbox() */
-    tool_tips = gtk_tooltips_new ();
-    
   s_width = gdk_screen_width ();
   s_height = gdk_screen_height ();
   if (width > s_width)
@@ -816,7 +811,7 @@ create_display_shell(DDisplay *ddisp,
       GTK_WIDGET_UNSET_FLAGS(ddisp->origin, GTK_CAN_FOCUS);
       widget = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
       gtk_container_add(GTK_CONTAINER(ddisp->origin), widget);
-      gtk_tooltips_set_tip(tool_tips, widget, _("Diagram menu."), NULL);
+      gtk_widget_set_tooltip_text(widget, _("Diagram menu."));
       gtk_widget_show(widget);
       g_signal_connect(GTK_OBJECT(ddisp->origin), "button_press_event",
 		     G_CALLBACK(origin_button_press), ddisp);
@@ -853,8 +848,8 @@ create_display_shell(DDisplay *ddisp,
 
   /*  Popup button between scrollbars for navigation window  */
   navigation_button = navigation_popup_new(ddisp);
-  gtk_tooltips_set_tip(tool_tips, navigation_button,
-                       _("Pops up the Navigation window."), NULL);
+  gtk_widget_set_tooltip_text(navigation_button,
+                       _("Pops up the Navigation window."));
   gtk_widget_show(navigation_button);
 
   /*  Canvas  */
@@ -933,8 +928,8 @@ create_display_shell(DDisplay *ddisp,
   
   g_signal_connect(G_OBJECT(ddisp->grid_status), "toggled",
 		   G_CALLBACK (grid_toggle_snap), ddisp);
-  gtk_tooltips_set_tip(tool_tips, ddisp->grid_status,
-		       _("Toggles snap-to-grid for this window."), NULL);
+  gtk_widget_set_tooltip_text(ddisp->grid_status,
+		       _("Toggles snap-to-grid for this window."));
   gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->grid_status,
 		      FALSE, FALSE, 0);
 
@@ -944,8 +939,8 @@ create_display_shell(DDisplay *ddisp,
   
   g_signal_connect(G_OBJECT(ddisp->mainpoint_status), "toggled",
 		   G_CALLBACK (interface_toggle_mainpoint_magnetism), ddisp);
-  gtk_tooltips_set_tip(tool_tips, ddisp->mainpoint_status,
-		       _("Toggles object snapping for this window."), NULL);
+  gtk_widget_set_tooltip_text(ddisp->mainpoint_status,
+		       _("Toggles object snapping for this window."));
   gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->mainpoint_status,
 		      FALSE, FALSE, 0);
 
@@ -1182,13 +1177,13 @@ create_tools(GtkWidget *parent)
 
 	alabel = gtk_accelerator_get_label(key, mods);
 	atip = g_strconcat(gettext(tool_data[i].tool_desc), " (", alabel, ")", NULL);
-	gtk_tooltips_set_tip (tool_tips, button, atip, NULL);
+	gtk_widget_set_tooltip_text (button, atip);
 	g_free (atip);
 	g_free (alabel);
 
     } else {
-	gtk_tooltips_set_tip (tool_tips, button,
-				gettext(tool_data[i].tool_desc), NULL);
+	gtk_widget_set_tooltip_text (button,
+				gettext(tool_data[i].tool_desc));
     }
     
     gtk_widget_show (pixmapwidget);
@@ -1318,8 +1313,7 @@ fill_sheet_wbox(Sheet *sheet)
 
     tool_setup_drag_source(button, data, pixmap, mask);
 
-    gtk_tooltips_set_tip (tool_tips, button,
-			  gettext(sheet_obj->description), NULL);
+    gtk_widget_set_tooltip_text (button, gettext(sheet_obj->description));
   }
   /* If the selection is in the old sheet, steal it */
   if (active_tool != NULL &&
@@ -1492,12 +1486,11 @@ create_color_area (GtkWidget *parent)
 
   gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
 
-  gtk_tooltips_set_tip (tool_tips, col_area, 
+  gtk_widget_set_tooltip_text (col_area, 
 			_("Foreground & background colors for new objects.  "
 			  "The small black and white squares reset colors.  "
 			  "The small arrows swap colors.  Double click to "
-			  "change colors."),
-                        NULL);
+			  "change colors."));
 
   gtk_widget_show (alignment);
   
@@ -1508,7 +1501,7 @@ create_color_area (GtkWidget *parent)
   line_area = linewidth_area_create ();
   gtk_container_add (GTK_CONTAINER (alignment), line_area);
   gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
-  gtk_tooltips_set_tip(tool_tips, line_area, _("Line widths.  Click on a line to set the default line width for new objects.  Double-click to set the line width more precisely."), NULL);
+  gtk_widget_set_tooltip_text(line_area, _("Line widths.  Click on a line to set the default line width for new objects.  Double-click to set the line width more precisely."));
   gtk_widget_show (alignment);
 
   gtk_widget_show (col_area);
@@ -1542,7 +1535,7 @@ create_lineprops_area(GtkWidget *parent)
   LineStyle style;
   gchar *arrow_name;
 
-  chooser = dia_arrow_chooser_new(TRUE, change_start_arrow_style, NULL, tool_tips);
+  chooser = dia_arrow_chooser_new(TRUE, change_start_arrow_style, NULL);
   gtk_wrap_box_pack_wrapped(GTK_WRAP_BOX(parent), chooser, FALSE, TRUE, FALSE, TRUE, TRUE);
   arrow.width = persistence_register_real("start-arrow-width", DEFAULT_ARROW_WIDTH);
   arrow.length = persistence_register_real("start-arrow-length", DEFAULT_ARROW_LENGTH);
@@ -1551,18 +1544,18 @@ create_lineprops_area(GtkWidget *parent)
   g_free(arrow_name);
   dia_arrow_chooser_set_arrow(DIA_ARROW_CHOOSER(chooser), &arrow);
   attributes_set_default_start_arrow(arrow);
-  gtk_tooltips_set_tip(tool_tips, chooser, _("Arrow style at the beginning of new lines.  Click to pick an arrow, or set arrow parameters with Details..."), NULL);
+  gtk_widget_set_tooltip_text(chooser, _("Arrow style at the beginning of new lines.  Click to pick an arrow, or set arrow parameters with Details..."));
   gtk_widget_show(chooser);
 
   chooser = dia_line_chooser_new(change_line_style, NULL);
   gtk_wrap_box_pack(GTK_WRAP_BOX(parent), chooser, TRUE, TRUE, FALSE, TRUE);
-  gtk_tooltips_set_tip(tool_tips, chooser, _("Line style for new lines.  Click to pick a line style, or set line style parameters with Details..."), NULL);
+  gtk_widget_set_tooltip_text (chooser, _("Line style for new lines.  Click to pick a line style, or set line style parameters with Details..."));
   style = persistence_register_integer("line-style", LINESTYLE_SOLID);
   dash_length = persistence_register_real("dash-length", DEFAULT_LINESTYLE_DASHLEN);
   dia_line_chooser_set_line_style(DIA_LINE_CHOOSER(chooser), style, dash_length);
   gtk_widget_show(chooser);
 
-  chooser = dia_arrow_chooser_new(FALSE, change_end_arrow_style, NULL, tool_tips);
+  chooser = dia_arrow_chooser_new(FALSE, change_end_arrow_style, NULL);
   arrow.width = persistence_register_real("end-arrow-width", DEFAULT_ARROW_WIDTH);
   arrow.length = persistence_register_real("end-arrow-length", DEFAULT_ARROW_LENGTH);
   arrow_name = persistence_register_string("end-arrow-type", "Filled Concave");
@@ -1572,7 +1565,7 @@ create_lineprops_area(GtkWidget *parent)
   attributes_set_default_end_arrow(arrow);
 
   gtk_wrap_box_pack(GTK_WRAP_BOX(parent), chooser, FALSE, TRUE, FALSE, TRUE);
-  gtk_tooltips_set_tip(tool_tips, chooser, _("Arrow style at the end of new lines.  Click to pick an arrow, or set arrow parameters with Details..."), NULL);
+  gtk_widget_set_tooltip_text(chooser, _("Arrow style at the end of new lines.  Click to pick an arrow, or set arrow parameters with Details..."));
   gtk_widget_show(chooser);
 }
 
@@ -1682,9 +1675,6 @@ create_integrated_ui (void)
   gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); 
   gtk_widget_show (notebook);
 
-  /*  tooltips  */
-  tool_tips = gtk_tooltips_new ();
-
   wrapbox = gtk_hwrap_box_new(FALSE);
   gtk_wrap_box_set_aspect_ratio(GTK_WRAP_BOX(wrapbox), 144.0 / 318.0);
   gtk_wrap_box_set_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_TOP);
@@ -1794,13 +1784,6 @@ create_toolbox ()
 #endif
   gtk_widget_show (main_vbox);
 
-  /*  tooltips  */
-  tool_tips = gtk_tooltips_new ();
-
-  /*  gtk_tooltips_set_colors (tool_tips,
-			   &colors[11],
-			   &main_vbox->style->fg[GTK_STATE_NORMAL]);*/
-
   wrapbox = gtk_hwrap_box_new(FALSE);
   gtk_wrap_box_set_aspect_ratio(GTK_WRAP_BOX(wrapbox), 144.0 / 318.0);
   gtk_wrap_box_set_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_TOP);
diff --git a/app/interface.h b/app/interface.h
index 5cbea1a..d0c081f 100644
--- a/app/interface.h
+++ b/app/interface.h
@@ -100,10 +100,6 @@ extern gchar *interface_current_sheet_name;
 void tool_select_update (GtkWidget *w, gpointer   data);
 void fill_sheet_menu(void);
 
-#ifndef GTK_DISABLE_DEPRECATED
-extern GtkTooltips *tool_tips;
-#endif
-
 void close_notebook_page_callback (GtkButton *button, gpointer user_data);
 
 #endif /* INTERFACE_H */
diff --git a/app/layer_dialog.c b/app/layer_dialog.c
index 8850644..8cc7ea3 100644
--- a/app/layer_dialog.c
+++ b/app/layer_dialog.c
@@ -208,8 +208,7 @@ create_button_box(GtkWidget *parent, gboolean show_labels)
 			     G_CALLBACK(buttons[i].callback),
 			       GTK_OBJECT (parent));
           
-    if (tool_tips != NULL)
-      gtk_tooltips_set_tip (tool_tips, button, gettext(buttons[i].tooltip), NULL);
+    gtk_widget_set_tooltip_text (button, gettext(buttons[i].tooltip));
 
     gtk_box_pack_start (GTK_BOX(button_box), button, TRUE, TRUE, 0);
 
diff --git a/app/menus.c b/app/menus.c
index 69d3855..5af14f7 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -21,7 +21,7 @@
 #include <config.h>
 #endif
 
-#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
+#undef GTK_DISABLE_DEPRECATED /* watch out sheets.h dragging in gnome.h */
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
@@ -604,8 +604,7 @@ create_integrated_ui_toolbar (void)
                                         dia_off_grid_icon);
   g_signal_connect (G_OBJECT (w), "toggled",
 		   G_CALLBACK (integrated_ui_toolbar_grid_snap_toggle), toolbar);
-  gtk_tooltips_set_tip (tool_tips, w,
-		      _("Toggles snap-to-grid."), NULL);
+  gtk_widget_set_tooltip_text (w, _("Toggles snap-to-grid."));
   g_object_set_data (G_OBJECT (toolbar), 
                      DIA_INTEGRATED_TOOLBAR_SNAP_GRID,
                      w);
@@ -616,8 +615,7 @@ create_integrated_ui_toolbar (void)
                                         dia_mainpoints_off_icon);
   g_signal_connect (G_OBJECT (w), "toggled",
 		   G_CALLBACK (integrated_ui_toolbar_object_snap_toggle), toolbar);
-  gtk_tooltips_set_tip (tool_tips, w,
-		       _("Toggles object snapping."), NULL);
+  gtk_widget_set_tooltip_text (w, _("Toggles object snapping."));
   g_object_set_data (G_OBJECT (toolbar), 
                      DIA_INTEGRATED_TOOLBAR_OBJECT_SNAP,
                      w);
@@ -812,7 +810,7 @@ _ui_manager_connect_proxy (GtkUIManager *manager,
 
       if (tooltip)
         {
-	  gtk_tooltips_set_tip (tool_tips, proxy, tooltip, NULL);
+	  gtk_widget_set_tooltip_text (proxy, tooltip);
 	  g_free (tooltip);
 	}
     }
diff --git a/lib/diaarrowchooser.c b/lib/diaarrowchooser.c
index 7a45573..90137fb 100644
--- a/lib/diaarrowchooser.c
+++ b/lib/diaarrowchooser.c
@@ -22,10 +22,9 @@
 /** \file diaarrowchooser.c  A widget to choose arrowhead.  This only select arrowhead, not width  and height. 
  * \ingroup diawidgets
  */
-#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
-
-#include <gtk/gtk.h>
 #include <config.h>
+#undef GTK_DISABLE_DEPRECATED /* e.g. gtk_object_get_data */
+#include <gtk/gtk.h>
 #include "intl.h"
 #include "widgets.h"
 #include "diaarrowchooser.h"
@@ -411,12 +410,11 @@ dia_arrow_chooser_change_arrow_type(GtkMenuItem *mi, DiaArrowChooser *chooser)
  * @param callback void (*callback)(Arrow *arrow, gpointer user_data) which
  *                 will be called when the arrow type or dimensions change.
  * @param user_data Any user data.  This will be stored in chooser->user_data.
- * @param tool_tips An object to set arrow names with.
  * @return A new DiaArrowChooser widget.
  */
 GtkWidget *
 dia_arrow_chooser_new(gboolean left, DiaChangeArrowCallback callback,
-		      gpointer user_data, GtkTooltips *tool_tips)
+		      gpointer user_data)
 {
   DiaArrowChooser *chooser = g_object_new(DIA_TYPE_ARROW_CHOOSER, NULL);
   GtkWidget *menu, *mi, *ar;
@@ -438,9 +436,7 @@ dia_arrow_chooser_new(gboolean left, DiaChangeArrowCallback callback,
     mi = gtk_menu_item_new();
     g_object_set_data(G_OBJECT(mi), menuitem_enum_key,
 		      GINT_TO_POINTER(arrow_type));
-    if (tool_tips) {
-      gtk_tooltips_set_tip(tool_tips, mi, _dia_translate(arrow_get_name_from_type(arrow_type), NULL), NULL);
-    }
+    gtk_widget_set_tooltip_text(mi, _dia_translate(arrow_get_name_from_type(arrow_type), NULL));
     ar = dia_arrow_preview_new(arrow_type, left);
 
     gtk_container_add(GTK_CONTAINER(mi), ar);
diff --git a/lib/diaarrowchooser.h b/lib/diaarrowchooser.h
index a63b7d3..f8d7766 100644
--- a/lib/diaarrowchooser.h
+++ b/lib/diaarrowchooser.h
@@ -92,13 +92,7 @@ struct _DiaArrowChooserClass
 
 GtkWidget *dia_arrow_chooser_new (gboolean left,
 				  DiaChangeArrowCallback callback,
-				  gpointer user_data, 
-#ifndef GTK_DISABLE_DEPRECATED
-				  GtkTooltips *tool_tips
-#else
-				  gpointer     tool_tips
-#endif
-				  );
+				  gpointer user_data);
 void dia_arrow_chooser_set_arrow(DiaArrowChooser *chooser, Arrow *arrow);
 ArrowType dia_arrow_chooser_get_arrow_type(DiaArrowChooser *chooser);
 



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