Commit c651fba1 authored by Christian Persch's avatar Christian Persch Committed by Christian Persch

Port to gtk 2.12 tooltips API. Bug #500947. Remove the unnecessary event

2007-12-19  Christian Persch  <chpe@gnome.org>

	* configure.ac:
	* gladeui/glade-app.c: (glade_app_refresh_undo_redo_button):
	* gladeui/glade-base-editor.c: (glade_base_editor_add_properties):
	* gladeui/glade-editor-property.c:
	(glade_editor_property_tooltip_cb),
	(glade_editor_property_sensitivity_cb),
	(glade_editor_property_create_info_button),
	(glade_editor_property_constructor),
	(glade_editor_property_finalize),
	(glade_editor_property_load_common),
	(glade_eprop_text_show_i18n_dialog),
	(glade_eprop_adjustment_table_add_label):
	* gladeui/glade-editor-property.h:
	* gladeui/glade-editor.c: (glade_editor_notebook_page),
	(glade_editor_create_info_button),
	(glade_editor_create_reset_button),
	(glade_editor_table_append_item):
	* gladeui/glade-palette.c: (glade_palette_dispose),
	(glade_palette_new_item), (glade_palette_new_item_group),
	(glade_palette_update_appearance), (glade_palette_init):
	* gladeui/glade-project.c: (glade_project_dispose),
	(glade_project_init):
	* gladeui/glade-project.h:
	* gladeui/glade-property-class.c:
	(glade_property_class_new_from_spec):
	* gladeui/glade-utils.c:
	* gladeui/glade-widget.c: (expose_draw_selection):
	* plugins/gtk+/glade-gtk.c: (glade_gtk_widget_set_property),
	(glade_gtk_widget_get_property):
	* src/glade-window.c: (format_project_list_item_tooltip),
	(refresh_projects_list_menu), (glade_window_init): Port to gtk 2.12
	tooltips API. Bug #500947. Remove the unnecessary event boxes on the property
	labels, part of bug #490157.

svn path=/trunk/; revision=1660
parent e2e1a3a0
2007-12-19 Christian Persch <chpe@gnome.org>
* configure.ac:
* gladeui/glade-app.c: (glade_app_refresh_undo_redo_button):
* gladeui/glade-base-editor.c: (glade_base_editor_add_properties):
* gladeui/glade-editor-property.c:
(glade_editor_property_tooltip_cb),
(glade_editor_property_sensitivity_cb),
(glade_editor_property_create_info_button),
(glade_editor_property_constructor),
(glade_editor_property_finalize),
(glade_editor_property_load_common),
(glade_eprop_text_show_i18n_dialog),
(glade_eprop_adjustment_table_add_label):
* gladeui/glade-editor-property.h:
* gladeui/glade-editor.c: (glade_editor_notebook_page),
(glade_editor_create_info_button),
(glade_editor_create_reset_button),
(glade_editor_table_append_item):
* gladeui/glade-palette.c: (glade_palette_dispose),
(glade_palette_new_item), (glade_palette_new_item_group),
(glade_palette_update_appearance), (glade_palette_init):
* gladeui/glade-project.c: (glade_project_dispose),
(glade_project_init):
* gladeui/glade-project.h:
* gladeui/glade-property-class.c:
(glade_property_class_new_from_spec):
* gladeui/glade-utils.c:
* gladeui/glade-widget.c: (expose_draw_selection):
* plugins/gtk+/glade-gtk.c: (glade_gtk_widget_set_property),
(glade_gtk_widget_get_property):
* src/glade-window.c: (format_project_list_item_tooltip),
(refresh_projects_list_menu), (glade_window_init): Port to gtk 2.12
tooltips API. Bug #500947. Remove the unnecessary event boxes on the property
labels, part of bug #490157.
2007-12-18 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* NEWS, configure.ac: Rolling 3.4.1
......
......@@ -116,7 +116,7 @@ GTK_DOC_CHECK(1.4)
dnl ================================================================
dnl Check for gtk+
dnl ================================================================
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.10.0 gthread-2.0 libxml-2.0 >= 2.4.0])
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.12.0 gthread-2.0 libxml-2.0 >= 2.4.0])
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
......
......@@ -252,13 +252,9 @@ glade_app_refresh_undo_redo_button (GladeApp *app,
gboolean undo)
{
GladeCommand *command = NULL;
static GtkTooltips *button_tips = NULL;
GladeProject *project;
gchar *desc;
if (button_tips == NULL)
button_tips = gtk_tooltips_new ();
if ((project = glade_app_get_project ()) != NULL)
{
if (undo)
......@@ -270,7 +266,7 @@ glade_app_refresh_undo_redo_button (GladeApp *app,
/* Change tooltips */
desc = g_strdup_printf ((undo) ? _("Undo: %s") : _("Redo: %s"),
command ? command->description : _("the last action"));
gtk_tooltips_set_tip (GTK_TOOLTIPS (button_tips), button, desc, NULL);
gtk_widget_set_tooltip_text (button, desc);
g_free (desc);
/* Set sensitivity on the button */
......
......@@ -1662,7 +1662,7 @@ glade_base_editor_add_properties (GladeBaseEditor *editor,
eprop = glade_editor_property_new_from_widget (gchild, property, packing, TRUE);
if (eprop)
glade_base_editor_table_attach (editor,
GLADE_EDITOR_PROPERTY (eprop)->eventbox,
GLADE_EDITOR_PROPERTY (eprop)->item_label,
GTK_WIDGET (eprop));
property = va_arg (args, gchar *);
}
......
......@@ -162,24 +162,8 @@ glade_editor_property_tooltip_cb (GladeProperty *property,
const gchar *tooltip,
GladeEditorProperty *eprop)
{
glade_util_widget_set_tooltip (eprop->input, tooltip);
glade_util_widget_set_tooltip (eprop->eventbox, tooltip);
}
static void
glade_eprop_label_style_update_cb (GtkWidget *label,
GtkStyle *prev,
GladeEditorProperty *eprop)
{
if (eprop->insensitive_colour)
gdk_color_free (eprop->insensitive_colour);
if (eprop->normal_colour)
gdk_color_free (eprop->normal_colour);
eprop->insensitive_colour =
gdk_color_copy (&(label->style->fg[GTK_STATE_INSENSITIVE]));
eprop->normal_colour =
gdk_color_copy (&(label->style->fg[GTK_STATE_NORMAL]));
gtk_widget_set_tooltip_text (eprop->input, tooltip);
gtk_widget_set_tooltip_text (eprop->item_label, tooltip);
}
static void
......@@ -189,20 +173,9 @@ glade_editor_property_sensitivity_cb (GladeProperty *property,
{
gboolean sensitive = glade_property_get_sensitive (eprop->property);
g_signal_handlers_block_by_func
(eprop->item_label, glade_eprop_label_style_update_cb, eprop);
gtk_widget_modify_fg
(GTK_WIDGET (eprop->item_label),
GTK_STATE_NORMAL,
sensitive ? eprop->normal_colour : eprop->insensitive_colour);
g_signal_handlers_unblock_by_func
(eprop->item_label, glade_eprop_label_style_update_cb, eprop);
if (sensitive == FALSE)
gtk_widget_set_sensitive (eprop->input, FALSE);
else if (glade_property_get_enabled (property) != FALSE)
gtk_widget_set_sensitive (eprop->input, TRUE);
gtk_widget_set_sensitive (eprop->item_label, sensitive);
gtk_widget_set_sensitive (eprop->input, sensitive &&
glade_property_get_enabled (property));
if (eprop->check)
gtk_widget_set_sensitive (eprop->check, sensitive);
}
......@@ -281,7 +254,7 @@ glade_editor_property_create_info_button (GladeEditorProperty *eprop)
gtk_container_add (GTK_CONTAINER (button), image);
glade_util_widget_set_tooltip (button, _("View GTK+ documentation for this property"));
gtk_widget_set_tooltip_text (button, _("View GTK+ documentation for this property"));
return button;
}
......@@ -301,23 +274,12 @@ glade_editor_property_constructor (GType type,
eprop = GLADE_EDITOR_PROPERTY (obj);
/* Create label (make label visible but not the eventbox) */
/* Create label */
text = g_strdup_printf ("%s:", eprop->klass->name);
eprop->item_label = gtk_label_new (text);
eprop->eventbox = gtk_event_box_new ();
g_free (text);
gtk_widget_show (eprop->item_label);
/* Deal with label colours */
glade_eprop_label_style_update_cb (eprop->item_label, NULL, eprop);
g_signal_connect (G_OBJECT (eprop->item_label), "style-set",
G_CALLBACK (glade_eprop_label_style_update_cb), eprop);
/* keep our own reference */
g_object_ref (G_OBJECT (eprop->eventbox));
gtk_misc_set_alignment (GTK_MISC (eprop->item_label), 1.0, 0.5);
gtk_container_add (GTK_CONTAINER (eprop->eventbox), eprop->item_label);
/* Create hbox and possibly check button
*/
......@@ -328,7 +290,6 @@ glade_editor_property_constructor (GType type,
gtk_box_pack_start (GTK_BOX (eprop), eprop->check, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (eprop->check), "toggled",
G_CALLBACK (glade_editor_property_enabled_toggled_cb), eprop);
}
/* Create the class specific input widget and add it */
......@@ -355,11 +316,6 @@ glade_editor_property_finalize (GObject *object)
/* detatch from loaded property */
glade_editor_property_load_common (eprop, NULL);
if (eprop->insensitive_colour)
gdk_color_free (eprop->insensitive_colour);
if (eprop->normal_colour)
gdk_color_free (eprop->normal_colour);
G_OBJECT_CLASS (table_class)->finalize (object);
}
......@@ -437,12 +393,12 @@ glade_editor_property_load_common (GladeEditorProperty *eprop,
if (property)
{
gtk_widget_show (GTK_WIDGET (eprop));
gtk_widget_show (eprop->eventbox);
gtk_widget_show (eprop->item_label);
}
else
{
gtk_widget_hide (GTK_WIDGET (eprop));
gtk_widget_hide (eprop->eventbox);
gtk_widget_hide (eprop->item_label);
}
/* disconnect anything from previously loaded property */
......@@ -1759,7 +1715,7 @@ glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
if ((pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (eprop->property),
"i18n-translatable")) != NULL)
glade_util_widget_set_tooltip (translatable_button,
gtk_widget_set_tooltip_text (translatable_button,
g_param_spec_get_blurb (pspec));
context_button = gtk_check_button_new_with_mnemonic (_("_Has context prefix"));
......@@ -1772,7 +1728,7 @@ glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
if ((pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (eprop->property),
"i18n-has-context")) != NULL)
glade_util_widget_set_tooltip (context_button,
gtk_widget_set_tooltip_text (context_button,
g_param_spec_get_blurb (pspec));
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
......@@ -3136,16 +3092,14 @@ glade_eprop_adjustment_table_add_label (GtkTable *table,
gchar *label,
gchar *tip)
{
GtkWidget *widget, *eventbox = gtk_event_box_new ();
GtkWidget *widget;
widget = gtk_label_new (label);
gtk_misc_set_alignment (GTK_MISC (widget), 1, 0);
gtk_container_add (GTK_CONTAINER (eventbox), widget);
glade_util_widget_set_tooltip (eventbox, tip);
gtk_widget_set_tooltip_text (widget, tip);
gtk_table_attach_defaults (table, eventbox, 0, 1, pos, pos + 1);
gtk_table_attach_defaults (table, widget, 0, 1, pos, pos + 1);
}
static GtkWidget *
......
......@@ -26,9 +26,6 @@ struct _GladeEditorProperty
GtkWidget *item_label; /* Name of property (need a handle to set visual insensitive state)
*/
GtkWidget *eventbox; /* Eventbox on item_label.
*/
GtkWidget *input; /* Input part of property (need to set sensitivity seperately)
*/
......@@ -55,12 +52,6 @@ struct _GladeEditorProperty
gboolean show_info; /* Whether we should show an informational button
* for this property
*/
GdkColor *insensitive_colour; /* For setting insensitive background on */
GdkColor *normal_colour; /* labels without setting them insensitive
* (tooltips dont work on insensitive widgets
* at this time)
*/
};
struct _GladeEditorPropertyClass {
......
......@@ -199,7 +199,7 @@ glade_editor_notebook_page (GladeEditor *editor, const gchar *name)
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 0);
/* construct tab label widget */
if (g_utf8_collate (name, _("Accessibility")) == 0)
if (strcmp (name, _("Accessibility")) == 0)
{
path = g_build_filename (glade_app_get_pixmaps_dir (), "atk.png", NULL);
image = gtk_image_new_from_file (path);
......@@ -208,7 +208,7 @@ glade_editor_notebook_page (GladeEditor *editor, const gchar *name)
gtk_widget_show (label_widget);
gtk_widget_show (image);
glade_util_widget_set_tooltip (label_widget, name);
gtk_widget_set_tooltip_text (label_widget, name);
}
else
{
......@@ -216,7 +216,7 @@ glade_editor_notebook_page (GladeEditor *editor, const gchar *name)
}
/* configure page container */
if (g_utf8_collate (name, _("_Signals")) == 0)
if (strcmp (name, _("_Signals")) == 0)
{
gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.5, 0.5, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 0, 0);
......@@ -280,7 +280,7 @@ glade_editor_create_info_button (GladeEditor *editor)
gtk_container_add (GTK_CONTAINER (button), image);
glade_util_widget_set_tooltip (button, _("View documentation for the selected widget"));
gtk_widget_set_tooltip_text (button, _("View documentation for the selected widget"));
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (glade_editor_on_docs_click), editor);
......@@ -300,7 +300,7 @@ glade_editor_create_reset_button (GladeEditor *editor)
gtk_container_add (GTK_CONTAINER (button), image);
glade_util_widget_set_tooltip (button, _("Reset widget properties to their defaults"));
gtk_widget_set_tooltip_text (button, _("Reset widget properties to their defaults"));
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (glade_editor_on_reset_click), editor);
......@@ -445,7 +445,7 @@ glade_editor_table_append_item (GladeEditorTable *table,
property = glade_editor_property_new (klass, from_query_dialog == FALSE);
gtk_widget_show (GTK_WIDGET (property));
gtk_widget_show_all (property->eventbox);
gtk_widget_show_all (property->item_label);
if (table->editor->show_context_info && from_query_dialog == FALSE)
glade_editor_property_show_info (property);
......@@ -456,7 +456,7 @@ glade_editor_table_append_item (GladeEditorTable *table,
G_CALLBACK (glade_editor_gtk_doc_search_cb),
table->editor);
glade_editor_table_attach (table->table_widget, property->eventbox, 0, table->rows);
glade_editor_table_attach (table->table_widget, property->item_label, 0, table->rows);
glade_editor_table_attach (table->table_widget, GTK_WIDGET (property), 1, table->rows);
table->rows++;
......
......@@ -69,9 +69,6 @@ struct _GladePalettePrivate
GSList *sections; /* List of GladePaletteExpanders */
GtkTooltips *tooltips; /* Tooltips for the item buttons */
GtkTooltips *static_tooltips; /* These tooltips never get disabled */
GtkSizeGroup *size_group; /* All items have the same dimensions */
GladeItemAppearance item_appearance;
......@@ -308,16 +305,6 @@ glade_palette_dispose (GObject *object)
g_object_unref (priv->tray);
priv->tray = NULL;
}
if (priv->tooltips)
{
g_object_unref (priv->tooltips);
priv->tooltips = NULL;
}
if (priv->static_tooltips)
{
g_object_unref (priv->static_tooltips);
priv->static_tooltips = NULL;
}
G_OBJECT_CLASS (glade_palette_parent_class)->dispose (object);
}
......@@ -468,7 +455,7 @@ glade_palette_new_item (GladePalette *palette, GladeWidgetAdaptor *adaptor)
glade_palette_item_set_appearance (GLADE_PALETTE_ITEM (item), priv->item_appearance);
gtk_tooltips_set_tip (priv->tooltips, item, adaptor->title, NULL);
gtk_widget_set_tooltip_text (item, adaptor->title);
g_signal_connect (G_OBJECT (item), "toggled",
G_CALLBACK (glade_palette_on_button_toggled), palette);
......@@ -484,7 +471,6 @@ glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
GtkWidget *box;
GtkWidget *item;
GList *l;
gchar *title;
g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
g_return_val_if_fail (group != NULL, NULL);
......@@ -504,10 +490,8 @@ glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
}
title = g_strdup_printf ("%s", glade_widget_group_get_title (group));
/* Put items box in a expander */
expander = glade_palette_expander_new (title);
expander = glade_palette_expander_new (glade_widget_group_get_title (group));
glade_palette_expander_set_spacing (GLADE_PALETTE_EXPANDER (expander), 2);
glade_palette_expander_set_use_markup (GLADE_PALETTE_EXPANDER (expander), TRUE);
gtk_container_set_border_width (GTK_CONTAINER (expander), 0);
......@@ -518,8 +502,6 @@ glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
gtk_container_add (GTK_CONTAINER (expander), box);
g_free (title);
return expander;
}
......@@ -549,9 +531,12 @@ glade_palette_update_appearance (GladePalette *palette)
GtkWidget *viewport;
GSList *sections;
GList *items, *i;
gboolean show_tooltips;
priv = GLADE_PALETTE_GET_PRIVATE (palette);
show_tooltips = priv->item_appearance == GLADE_ITEM_ICON_ONLY;
for (sections = priv->sections; sections; sections = sections->next)
{
items = gtk_container_get_children (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (sections->data))));
......@@ -560,6 +545,8 @@ glade_palette_update_appearance (GladePalette *palette)
{
glade_palette_item_set_appearance (GLADE_PALETTE_ITEM (i->data), priv->item_appearance);
glade_palette_item_set_use_small_icon (GLADE_PALETTE_ITEM (i->data), priv->use_small_item_icons);
g_object_set (i->data, "has-tooltip", show_tooltips, NULL);
}
g_list_free (items);
}
......@@ -575,12 +562,6 @@ glade_palette_update_appearance (GladePalette *palette)
gtk_container_remove (GTK_CONTAINER (viewport), priv->tray);
gtk_container_add (GTK_CONTAINER (viewport), priv->tray);
}
if (priv->item_appearance == GLADE_ITEM_ICON_ONLY)
gtk_tooltips_enable (priv->tooltips);
else
gtk_tooltips_disable (priv->tooltips);
}
static GtkWidget*
......@@ -635,13 +616,7 @@ glade_palette_init (GladePalette *palette)
gtk_widget_show (priv->selector_button);
gtk_widget_show (priv->selector_hbox);
/* create tooltips */
priv->tooltips = gtk_tooltips_new ();
g_object_ref_sink (GTK_OBJECT (priv->tooltips));
priv->static_tooltips = gtk_tooltips_new ();
g_object_ref_sink (GTK_OBJECT (priv->static_tooltips));
gtk_tooltips_set_tip (priv->static_tooltips, priv->selector_button, _("Widget selector"), NULL);
gtk_widget_set_tooltip_text (priv->selector_button, _("Widget selector"));
/* create size group */
priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
......
......@@ -106,7 +106,6 @@ struct _GladeProjectPrivate
GList *prev_redo_item; /* Points to the item previous to the redo items */
GHashTable *widget_names_allocator; /* hash table with the used widget names */
GHashTable *widget_old_names; /* widget -> old name of the widget */
GtkTooltips *tooltips;
GladeCommand *first_modification; /* we record the first modification, so that we
* can set "modification" to FALSE when we
......@@ -202,9 +201,6 @@ glade_project_dispose (GObject *object)
}
project->priv->objects = NULL;
gtk_object_destroy (GTK_OBJECT (project->priv->tooltips));
project->priv->tooltips = NULL;
G_OBJECT_CLASS (glade_project_parent_class)->dispose (object);
}
......@@ -489,7 +485,6 @@ glade_project_init (GladeProject *project)
priv->widget_old_names = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
priv->tooltips = gtk_tooltips_new ();
priv->accel_group = NULL;
priv->resources = g_hash_table_new_full (g_direct_hash,
......@@ -2036,19 +2031,6 @@ glade_project_reset_path (GladeProject *project)
project->priv->path = (g_free (project->priv->path), NULL);
}
/**
* glade_project_get_tooltips:
* @project: a #GladeProject
*
* Returns: a #GtkTooltips object containing all tooltips for @project
*/
GtkTooltips *
glade_project_get_tooltips (GladeProject *project)
{
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
return project->priv->tooltips;
}
/**
* glade_project_set_accel_group:
* @project: A #GladeProject
......
......@@ -110,8 +110,6 @@ char *glade_project_new_widget_name (GladeProject *project, const c
void glade_project_widget_name_changed (GladeProject *project, GladeWidget *widget,
const char *old_name);
GtkTooltips *glade_project_get_tooltips (GladeProject *project);
/* Selection */
gboolean glade_project_is_selected (GladeProject *project,
......
......@@ -1279,7 +1279,6 @@ glade_property_class_new_from_spec (gpointer handle,
property_class->id = g_strdup (spec->name);
property_class->name = g_strdup (g_param_spec_get_nick (spec));
/* If its on the GtkWidgetClass, it goes in "common"
* (unless stipulated otherwise in the xml file)
*/
......
......@@ -43,7 +43,6 @@
#include "glade-fixed.h"
#include <string.h>
#include <gtk/gtktooltips.h>
#include <gdk/gdkkeysyms.h>
#include <gmodule.h>
#include <glib/gi18n-lib.h>
......@@ -66,33 +65,6 @@
*/
static GList *glade_util_selection = NULL;
static GtkTooltips *glade_tooltips = NULL;
/**
* glade_util_widget_set_tooltip:
* @widget: a #GtkWidget
* @str: a string
*
* Creates a new tooltip from @str and sets @widget to use it.
*/
void
glade_util_widget_set_tooltip (GtkWidget *widget, const gchar *str)
{
g_return_if_fail (widget != NULL);
if (str == NULL)
return;
if (glade_tooltips == NULL)
{
glade_tooltips = gtk_tooltips_new ();
g_object_ref (G_OBJECT (glade_tooltips));
gtk_object_sink (GTK_OBJECT (glade_tooltips));
}
gtk_tooltips_set_tip (glade_tooltips, widget, str, NULL);
}
/**
* glade_util_compose_get_type_func:
* @name:
......
......@@ -1706,12 +1706,13 @@ glade_widget_set_adaptor (GladeWidget *widget, GladeWidgetAdaptor *adaptor)
glade_widget_set_actions (widget, adaptor);
}
static void
static gboolean
expose_draw_selection (GtkWidget *widget_gtk,
GdkEventExpose *event,
GladeWidget *gwidget)
{
glade_util_draw_selection_nodes (event->window);
return FALSE;
}
......
......@@ -283,22 +283,13 @@ glade_gtk_widget_set_property (GladeWidgetAdaptor *adaptor,
const gchar *id,
const GValue *value)
{
/* FIXME: is this still needed with the new gtk+ tooltips? */
if (!strcmp (id, "tooltip"))
{
GladeWidget *glade_widget = glade_widget_get_from_gobject (object);
GladeProject *project = glade_widget_get_project (glade_widget);
GtkTooltips *tooltips = glade_project_get_tooltips (project);
const gchar *tooltip;
/* TODO: handle GtkToolItems with gtk_tool_item_set_tooltip() */
tooltip = g_value_get_string (value);
if (tooltip && *tooltip)
gtk_tooltips_set_tip (tooltips, GTK_WIDGET (object), tooltip, NULL);
else
gtk_tooltips_set_tip (tooltips, GTK_WIDGET (object), NULL, NULL);
}
else
GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
id = "tooltip-text";
}
GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
}
void
......@@ -309,14 +300,10 @@ glade_gtk_widget_get_property (GladeWidgetAdaptor *adaptor,
{
if (!strcmp (id, "tooltip"))
{
GtkTooltipsData *tooltips_data = gtk_tooltips_data_get (GTK_WIDGET (object));
g_value_reset (value);
g_value_set_string (value,
tooltips_data ? tooltips_data->tip_text : NULL);
id = "tooltip-text";
}
else
GWA_GET_CLASS (G_TYPE_OBJECT)->get_property (adaptor, object, id, value);
GWA_GET_CLASS (G_TYPE_OBJECT)->get_property (adaptor, object, id, value);
}
static GList *
......
......@@ -87,8 +87,6 @@ struct _GladeWindowPrivate
GladeDesignView *active_view;
gint num_tabs;
GtkTooltips *tooltips;
GtkWidget *inspectors_notebook;
GtkWidget *statusbar; /* A pointer to the status bar. */
......@@ -711,20 +709,23 @@ format_project_list_item_tooltip (GladeProject *project)
if (glade_project_get_readonly (project))
{
tooltip = g_strdup_printf ("Activate '%s' %s",
/* FIXME add hint for translators */
tooltip = g_strdup_printf (_("Activate '%s' %s"),
path,
READONLY_INDICATOR);
}
else
{
tooltip = g_strdup_printf ("Activate '%s'", path);
/* FIXME add hint for translators */
tooltip = g_strdup_printf (_("Activate '%s'"), path);
}
g_free (path);
}
else
{
name = glade_project_get_name (project);
tooltip = g_strdup_printf ("Activate '%s'", name);
/* FIXME add hint for translators */
tooltip = g_strdup_printf (_("Activate '%s'"), name);
g_free (name);
}
......@@ -1079,10 +1080,10 @@ refresh_projects_list_menu (GladeWindow *window)
GtkWidget *view;
GladeProject *project;
GtkRadioAction *action;
gchar *action_name;
gchar action_name[32];
gchar *project_name;
gchar *tooltip;
gchar *accel;
gchar accel[7];
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
project = glade_design_view_get_project (GLADE_DESIGN_VIEW (view));
......@@ -1095,17 +1096,18 @@ refresh_projects_list_menu (GladeWindow *window)
* the problem is worked around, action with the same name always
* get the same accel.
*/
action_name = g_strdup_printf ("Tab_%d", i);
g_snprintf (action_name, sizeof (action_name), "Tab_%d", i);
project_name = get_formatted_project_name_for_display (project,
FORMAT_NAME_MARK_UNSAVED |
FORMAT_NAME_MIDDLE_TRUNCATE |
FORMAT_NAME_ESCAPE_UNDERSCORES);
tooltip = format_project_list_item_tooltip (project);
/* alt + 1, 2, 3... 0 to switch to the first ten tabs */
accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;
if (i < 10)
g_snprintf (accel, sizeof (accel), "<alt>%d", (i + 1) % 10);
else
accel[0] = '\0';
action = gtk_radio_action_new (action_name,
project_name,
......@@ -1117,10 +1119,8 @@ refresh_projects_list_menu (GladeWindow *window)
g_object_set_data (G_OBJECT (project), "project-list-action", action);
g_object_set_data (G_OBJECT (action), "project", project);
if (group != NULL)
gtk_radio_action_set_group (action, group);
/* note that group changes each time we add an action, so it must be updated */
gtk_radio_action_set_group (action, group);
group = gtk_radio_action_get_group (action);
gtk_action_group_add_action_with_accel (p->projects_list_menu_actions,
......@@ -1142,10 +1142,8 @@ refresh_projects_list_menu (GladeWindow *window)
g_object_unref (action);
g_free (action_name);
g_free (project_name);
g_free (tooltip);
g_free (accel);
}
p->projects_list_menu_ui_id = id;
......@@ -3048,22 +3046,15 @@ glade_window_init (GladeWindow *window)
gtk_box_pack_start (GTK_BOX (vbox), priv->toolbar, FALSE, TRUE, 0);
gtk_widget_show (priv->toolbar);
/* tooltips object */
priv->tooltips = gtk_tooltips_new ();
/* undo/redo buttons */
priv->undo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_UNDO);
priv->redo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_REDO);
gtk_widget_show (GTK_WIDGET (priv->undo));
gtk_widget_show (GTK_WIDGET (priv->redo));
gtk_menu_tool_button_set_arrow_tooltip (GTK_MENU_TOOL_BUTTON (priv->undo),
priv->tooltips,
_("Go back in undo history"),
NULL);
gtk_menu_tool_button_set_arrow_tooltip (GTK_MENU_TOOL_BUTTON (priv->redo),
priv->tooltips,
("Go forward in undo history"),
NULL);
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (priv->undo),
_("Go back in undo history"));
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (priv->redo),
_("Go forward in undo history"));
sep = GTK_WIDGET (gtk_separator_tool_item_new ());
gtk_widget_show (sep);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment