#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkobject.h"
-#include "gtktooltips.h"
+#include "gtktooltip.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkalias.h"
gulong manager_changed_id;
gulong populate_id;
-
- /* tooltips for our bookmark items*/
- GtkTooltips *tooltips;
};
enum {
priv->local_only = TRUE;
priv->limit = FALLBACK_ITEM_LIMIT;
-
priv->sort_type = GTK_RECENT_SORT_NONE;
-
priv->icon_size = FALLBACK_ICON_SIZE;
-
priv->label_width = DEFAULT_LABEL_WIDTH;
priv->first_recent_item_pos = -1;
priv->placeholder = NULL;
priv->current_filter = NULL;
-
- priv->tooltips = gtk_tooltips_new ();
- g_object_ref_sink (priv->tooltips);
}
static void
priv->populate_id = 0;
}
- if (priv->tooltips)
- {
- g_object_unref (priv->tooltips);
- priv->tooltips = NULL;
- }
-
if (priv->current_filter)
{
g_object_unref (priv->current_filter);
g_value_set_boolean (value, priv->show_icons);
break;
case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE:
- g_warning ("%s: Choosers of type `%s' do not support selecting multiple items.",
- G_STRFUNC,
- G_OBJECT_TYPE_NAME (object));
+ g_value_set_boolean (value, FALSE);
break;
case GTK_RECENT_CHOOSER_PROP_FILTER:
g_value_set_object (value, priv->current_filter);
GtkWidget *item)
{
GtkRecentChooserMenuPrivate *priv;
- gchar *path, *tip_text;
+ gchar *path;
g_assert (info != NULL);
g_assert (item != NULL);
priv = menu->priv;
- if (!priv->tooltips)
- return;
-
path = gtk_recent_info_get_uri_display (info);
if (path)
{
- tip_text = g_strdup_printf (_("Open '%s'"), path);
+ gchar *tip_text = g_strdup_printf (_("Open '%s'"), path);
- gtk_tooltips_set_tip (priv->tooltips,
- item,
- tip_text,
- NULL);
+ gtk_widget_set_tooltip_text (item, tip_text);
+ gtk_widget_set_has_tooltip (item, priv->show_tips);
g_free (path);
g_free (tip_text);
/* avoid clashing mnemonics */
if (count <= 10)
- text = g_strdup_printf ("_%d. %s", count, escaped);
+ /* This is the label format that is used for the first 10 items
+ * in a recent files menu. The %d is the number of the item,
+ * the %s is the name of the item. Please keep the _ in front
+ * of the number to give these menu items a mnemonic.
+ *
+ * Don't include the prefix "recent menu label|" in the translation.
+ */
+ text = g_strdup_printf (Q_("recent menu label|_%d. %s"), count, escaped);
else
- text = g_strdup_printf ("%d. %s", count, escaped);
+ /* This is the format that is used for items in a recent files menu.
+ * The %d is the number of the item, the %s is the name of the item.
+ *
+ * Don't include the prefix "recent menu label|" in the translation.
+ */
+ text = g_strdup_printf (Q_("recent menu label|%d. %s"), count, escaped);
item = gtk_image_menu_item_new_with_mnemonic (text);
pdata = (MenuPopulateData *) data;
priv = pdata->menu->priv;
- priv->populate_id = 0;
-
if (!pdata->items)
{
pdata->items = gtk_recent_chooser_get_items (GTK_RECENT_CHOOSER (pdata->menu));
/* show the placeholder here */
gtk_widget_show (pdata->placeholder);
pdata->displayed_items = 1;
+ priv->populate_id = 0;
return FALSE;
}
g_list_foreach (pdata->items, (GFunc) gtk_recent_info_unref, NULL);
g_list_free (pdata->items);
+ priv->populate_id = 0;
+
retval = FALSE;
}
else
{
MenuPopulateData *pdata = data;
- /* show the placeholder in case no item survived
- * the filtering process in the idle loop
- */
- if (!pdata->displayed_items)
- gtk_widget_show (pdata->placeholder);
- g_object_unref (pdata->placeholder);
-
- g_slice_free (MenuPopulateData, data);
+ if (pdata->menu->priv->populate_id == 0)
+ {
+ /* show the placeholder in case no item survived
+ * the filtering process in the idle loop
+ */
+ if (!pdata->displayed_items)
+ gtk_widget_show (pdata->placeholder);
+ g_object_unref (pdata->placeholder);
+
+ g_slice_free (MenuPopulateData, data);
+ }
}
static void
return FALLBACK_ICON_SIZE;
}
+static void
+foreach_set_shot_tips (GtkWidget *widget,
+ gpointer user_data)
+{
+ GtkRecentChooserMenu *menu = user_data;
+ GtkRecentChooserMenuPrivate *priv = menu->priv;
+ gboolean has_mark;
+
+ /* toggle the tooltip only on the items we create */
+ has_mark =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gtk-recent-menu-mark"));
+
+ if (has_mark)
+ gtk_widget_set_has_tooltip (widget, priv->show_tips);
+}
+
static void
gtk_recent_chooser_menu_set_show_tips (GtkRecentChooserMenu *menu,
gboolean show_tips)
{
- if (menu->priv->show_tips == show_tips)
+ GtkRecentChooserMenuPrivate *priv = menu->priv;
+
+ if (priv->show_tips == show_tips)
return;
- g_assert (menu->priv->tooltips != NULL);
-
- if (show_tips)
- gtk_tooltips_enable (menu->priv->tooltips);
- else
- gtk_tooltips_disable (menu->priv->tooltips);
-
- menu->priv->show_tips = show_tips;
+ priv->show_tips = show_tips;
+ gtk_container_foreach (GTK_CONTAINER (menu), foreach_set_shot_tips, menu);
}
/*