Ellipsize menu items referring to websites or bookmarks.
Originally menu items could in some cases become as wide as the whole screen, making working with menus rather hard. Now we ellipsize at 50 characters in the middle of the string.
This commit is contained in:
parent
1a0718805e
commit
30cbc635d6
4 changed files with 69 additions and 32 deletions
|
@ -986,7 +986,7 @@ _midori_browser_add_tab (MidoriBrowser* browser,
|
||||||
katze_throbber_set_static_pixbuf (KATZE_THROBBER (tab_icon), icon);
|
katze_throbber_set_static_pixbuf (KATZE_THROBBER (tab_icon), icon);
|
||||||
title = _midori_browser_get_tab_title (browser, widget);
|
title = _midori_browser_get_tab_title (browser, widget);
|
||||||
tab_title = gtk_label_new (title);
|
tab_title = gtk_label_new (title);
|
||||||
menuitem = gtk_image_menu_item_new_with_label (title);
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
||||||
gtk_image_new_from_pixbuf (icon));
|
gtk_image_new_from_pixbuf (icon));
|
||||||
g_object_unref (icon);
|
g_object_unref (icon);
|
||||||
|
@ -1730,19 +1730,25 @@ static void
|
||||||
midori_browser_menu_trash_activate_cb (GtkWidget* widget,
|
midori_browser_menu_trash_activate_cb (GtkWidget* widget,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
GtkWidget* menu = gtk_menu_new ();
|
GtkWidget* menu;
|
||||||
guint n = katze_array_get_length (browser->trash);
|
guint i, n;
|
||||||
|
KatzeXbelItem* item;
|
||||||
|
const gchar* title;
|
||||||
|
const gchar* uri;
|
||||||
GtkWidget* menuitem;
|
GtkWidget* menuitem;
|
||||||
guint i;
|
GtkWidget* icon;
|
||||||
|
GtkAction* action;
|
||||||
|
|
||||||
|
menu = gtk_menu_new ();
|
||||||
|
n = katze_array_get_length (browser->trash);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
KatzeXbelItem* item = katze_array_get_nth_item (browser->trash, i);
|
item = katze_array_get_nth_item (browser->trash, i);
|
||||||
const gchar* title = katze_xbel_item_get_title (item);
|
title = katze_xbel_item_get_title (item);
|
||||||
const gchar* uri = katze_xbel_bookmark_get_href (item);
|
uri = katze_xbel_bookmark_get_href (item);
|
||||||
menuitem = gtk_image_menu_item_new_with_label (title ? title : uri);
|
menuitem = sokoke_image_menu_item_new_ellipsized (title ? title : uri);
|
||||||
/* FIXME: Get the real icon */
|
/* FIXME: Get the real icon */
|
||||||
GtkWidget* icon = gtk_image_new_from_stock (GTK_STOCK_FILE,
|
icon = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
g_object_set_data (G_OBJECT (menuitem), "KatzeXbelItem", item);
|
g_object_set_data (G_OBJECT (menuitem), "KatzeXbelItem", item);
|
||||||
|
@ -1754,8 +1760,7 @@ midori_browser_menu_trash_activate_cb (GtkWidget* widget,
|
||||||
menuitem = gtk_separator_menu_item_new ();
|
menuitem = gtk_separator_menu_item_new ();
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
GtkAction* action = gtk_action_group_get_action (browser->action_group,
|
action = gtk_action_group_get_action (browser->action_group, "TrashEmpty");
|
||||||
"TrashEmpty");
|
|
||||||
menuitem = gtk_action_create_menu_item (action);
|
menuitem = gtk_action_create_menu_item (action);
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
|
@ -2124,7 +2129,7 @@ _action_location_secondary_icon_released (GtkAction* action,
|
||||||
title = uri;
|
title = uri;
|
||||||
if (!*title)
|
if (!*title)
|
||||||
title = uri;
|
title = uri;
|
||||||
menuitem = gtk_image_menu_item_new_with_label (title);
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
||||||
/* FIXME: Get the real icon */
|
/* FIXME: Get the real icon */
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
|
||||||
menuitem), gtk_image_new_from_stock (STOCK_NEWS_FEED,
|
menuitem), gtk_image_new_from_stock (STOCK_NEWS_FEED,
|
||||||
|
@ -2403,38 +2408,40 @@ _midori_browser_create_bookmark_menu (MidoriBrowser* browser,
|
||||||
KatzeXbelItem* folder,
|
KatzeXbelItem* folder,
|
||||||
GtkWidget* menu)
|
GtkWidget* menu)
|
||||||
{
|
{
|
||||||
guint n = katze_xbel_folder_get_n_items (folder);
|
guint i, n;
|
||||||
guint i;
|
KatzeXbelItem* item;
|
||||||
|
const gchar* title;
|
||||||
|
GtkWidget* menuitem;
|
||||||
|
GtkWidget* submenu;
|
||||||
|
GtkWidget* icon;
|
||||||
|
|
||||||
|
n = katze_xbel_folder_get_n_items (folder);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
KatzeXbelItem* item = katze_xbel_folder_get_nth_item (folder, i);
|
item = katze_xbel_folder_get_nth_item (folder, i);
|
||||||
const gchar* title = katze_xbel_item_is_separator (item)
|
title = katze_xbel_item_is_separator (item)
|
||||||
? "" : katze_xbel_item_get_title (item);
|
? "" : katze_xbel_item_get_title (item);
|
||||||
/* const gchar* desc = katze_xbel_item_is_separator (item)
|
|
||||||
? "" : katze_xbel_item_get_desc (item); */
|
|
||||||
GtkWidget* menuitem = NULL;
|
|
||||||
switch (katze_xbel_item_get_kind (item))
|
switch (katze_xbel_item_get_kind (item))
|
||||||
{
|
{
|
||||||
case KATZE_XBEL_ITEM_KIND_FOLDER:
|
case KATZE_XBEL_ITEM_KIND_FOLDER:
|
||||||
/* FIXME: what about katze_xbel_folder_is_folded? */
|
/* FIXME: what about katze_xbel_folder_is_folded? */
|
||||||
menuitem = gtk_image_menu_item_new_with_label (title);
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
||||||
gtk_image_new_from_stock (GTK_STOCK_DIRECTORY,
|
gtk_image_new_from_stock (GTK_STOCK_DIRECTORY,
|
||||||
GTK_ICON_SIZE_MENU));
|
GTK_ICON_SIZE_MENU));
|
||||||
GtkWidget* _menu = gtk_menu_new ();
|
submenu = gtk_menu_new ();
|
||||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), _menu);
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (midori_browser_bookmark_menu_folder_activate_cb),
|
G_CALLBACK (midori_browser_bookmark_menu_folder_activate_cb),
|
||||||
browser);
|
browser);
|
||||||
g_object_set_data (G_OBJECT (menuitem), "KatzeXbelItem", item);
|
g_object_set_data (G_OBJECT (menuitem), "KatzeXbelItem", item);
|
||||||
break;
|
break;
|
||||||
case KATZE_XBEL_ITEM_KIND_BOOKMARK:
|
case KATZE_XBEL_ITEM_KIND_BOOKMARK:
|
||||||
menuitem = gtk_image_menu_item_new_with_label (title);
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
||||||
GtkWidget* image = gtk_image_new_from_stock (STOCK_BOOKMARK,
|
icon = gtk_image_new_from_stock (STOCK_BOOKMARK, GTK_ICON_SIZE_MENU);
|
||||||
GTK_ICON_SIZE_MENU);
|
gtk_widget_show (icon);
|
||||||
gtk_widget_show (image);
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
|
||||||
image);
|
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
|
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
|
||||||
browser);
|
browser);
|
||||||
|
@ -2444,7 +2451,8 @@ _midori_browser_create_bookmark_menu (MidoriBrowser* browser,
|
||||||
menuitem = gtk_separator_menu_item_new ();
|
menuitem = gtk_separator_menu_item_new ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("Unknown xbel item kind");
|
menuitem = NULL;
|
||||||
|
g_warning ("Unknown XBEL item kind");
|
||||||
}
|
}
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
|
@ -3567,7 +3575,7 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_signal_connect (browser->find_highlight, "toggled",
|
g_signal_connect (browser->find_highlight, "toggled",
|
||||||
G_CALLBACK (_find_highlight_toggled), browser);
|
G_CALLBACK (_find_highlight_toggled), browser);
|
||||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_highlight),
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_highlight),
|
||||||
"Highlight Matches");
|
_("Highlight Matches"));
|
||||||
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_highlight), TRUE);
|
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_highlight), TRUE);
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_highlight, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_highlight, -1);
|
||||||
toolitem = gtk_separator_tool_item_new ();
|
toolitem = gtk_separator_tool_item_new ();
|
||||||
|
|
|
@ -965,7 +965,7 @@ midori_web_view_get_proxy_menu_item (MidoriWebView* web_view)
|
||||||
if (!web_view->menu_item)
|
if (!web_view->menu_item)
|
||||||
{
|
{
|
||||||
title = midori_web_view_get_display_title (web_view);
|
title = midori_web_view_get_display_title (web_view);
|
||||||
web_view->menu_item = gtk_image_menu_item_new_with_label (title);
|
web_view->menu_item = sokoke_image_menu_item_new_ellipsized (title);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (web_view->menu_item),
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (web_view->menu_item),
|
||||||
gtk_image_new_from_pixbuf (web_view->icon));
|
gtk_image_new_from_pixbuf (web_view->icon));
|
||||||
|
|
||||||
|
|
|
@ -666,6 +666,32 @@ sokoke_action_create_popup_menu_item (GtkAction* action)
|
||||||
return menuitem;
|
return menuitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sokoke_image_menu_item_new_ellipsized:
|
||||||
|
* @label: the text of the menu item
|
||||||
|
*
|
||||||
|
* Creates a new #GtkImageMenuItem containing an ellipsized label.
|
||||||
|
*
|
||||||
|
* Return value: a new #GtkImageMenuItem
|
||||||
|
**/
|
||||||
|
GtkWidget*
|
||||||
|
sokoke_image_menu_item_new_ellipsized (const gchar* label)
|
||||||
|
{
|
||||||
|
GtkWidget* menuitem;
|
||||||
|
GtkWidget* label_widget;
|
||||||
|
|
||||||
|
menuitem = gtk_image_menu_item_new ();
|
||||||
|
label_widget = gtk_label_new (label);
|
||||||
|
/* FIXME: Should text direction be respected here? */
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.0);
|
||||||
|
gtk_label_set_max_width_chars (GTK_LABEL (label_widget), 50);
|
||||||
|
gtk_label_set_ellipsize (GTK_LABEL (label_widget), PANGO_ELLIPSIZE_MIDDLE);
|
||||||
|
gtk_widget_show (label_widget);
|
||||||
|
gtk_container_add (GTK_CONTAINER (menuitem), label_widget);
|
||||||
|
|
||||||
|
return menuitem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sokoke_tree_view_get_selected_iter:
|
* sokoke_tree_view_get_selected_iter:
|
||||||
* @tree_view: a #GtkTreeView
|
* @tree_view: a #GtkTreeView
|
||||||
|
|
|
@ -131,6 +131,9 @@ sokoke_object_get_boolean (gpointer object,
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
sokoke_action_create_popup_menu_item (GtkAction* action);
|
sokoke_action_create_popup_menu_item (GtkAction* action);
|
||||||
|
|
||||||
|
GtkWidget*
|
||||||
|
sokoke_image_menu_item_new_ellipsized (const gchar* label);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sokoke_tree_view_get_selected_iter (GtkTreeView* tree_view,
|
sokoke_tree_view_get_selected_iter (GtkTreeView* tree_view,
|
||||||
GtkTreeModel** model,
|
GtkTreeModel** model,
|
||||||
|
|
Loading…
Reference in a new issue