aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv <[email protected]>2010-11-20 15:51:25 +0100
committerJan Djärv <[email protected]>2010-11-20 15:51:25 +0100
commitd2bd51898e48c2fd47a98a42654842a65feea7ad (patch)
tree445b7d1580622915a8b4d0e2886be772640face3 /src
parent0e7c0582af3a7ee210dfa6a1ab6c41b23bea1951 (diff)
Add keyword :vert-only for tool bar items with labels not shown horizontally.
* lisp/info.el (info-tool-bar-map): Add some :vert-only keywords. * lisp/tool-bar.el (tool-bar-setup): Add some :vert-only keywords. * src/dispextern.h (tool_bar_item_idx): Add TOOL_BAR_ITEM_VERT_ONLY. * src/gtkutil.c (xg_make_tool_item): Take vert_only as argument. Set important to ! vert_only. (xg_show_toolbar_item): Don't show label horizontally if tool item isn't important. (update_frame_tool_bar): Get TOOL_BAR_ITEM_VERT_ONLY and pass it to xg_make_tool_item, or update important on existing tool item. * src/keyboard.c (QCvert_only): New variable. (parse_tool_bar_item): Check for QCvert_only. (syms_of_keyboard): Initialize QCvert_only.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/dispextern.h3
-rw-r--r--src/gtkutil.c18
-rw-r--r--src/keyboard.c11
4 files changed, 39 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b7c1ef2c93..552d8efe6f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2010-11-20 Jan Djärv <[email protected]>
+
+ * gtkutil.c (xg_make_tool_item): Take vert_only as argument.
+ Set important to ! vert_only.
+ (xg_show_toolbar_item): Don't show label horizontally if
+ tool item isn't important.
+ (update_frame_tool_bar): Get TOOL_BAR_ITEM_VERT_ONLY and pass it to
+ xg_make_tool_item, or update important on existing tool item.
+
+ * keyboard.c (QCvert_only): New variable.
+ (parse_tool_bar_item): Check for QCvert_only.
+ (syms_of_keyboard): Initialize QCvert_only.
+
+ * dispextern.h (tool_bar_item_idx): Add TOOL_BAR_ITEM_VERT_ONLY.
+
2010-11-20 Eli Zaretskii <[email protected]>
* msdos.c (dos_rawgetc): Use gen_help_event, instead of doing the
diff --git a/src/dispextern.h b/src/dispextern.h
index 0030aa8f18..7426c03b5e 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2887,6 +2887,9 @@ enum tool_bar_item_idx
/* Label to show when text labels are enabled. */
TOOL_BAR_ITEM_LABEL,
+ /* If we shall show the label only below the icon and not beside it. */
+ TOOL_BAR_ITEM_VERT_ONLY,
+
/* Sentinel = number of slots in tool_bar_items occupied by one
tool-bar item. */
TOOL_BAR_ITEM_NSLOTS
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 7103d2b199..89b16a10fb 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4059,7 +4059,8 @@ xg_make_tool_item (FRAME_PTR f,
GtkWidget *wimage,
GtkWidget **wbutton,
const char *label,
- int i)
+ int i,
+ int vert_only)
{
GtkToolItem *ti = gtk_tool_item_new ();
Lisp_Object style = Ftool_bar_get_system_style ();
@@ -4071,6 +4072,10 @@ xg_make_tool_item (FRAME_PTR f,
GtkWidget *wb = gtk_button_new ();
GtkWidget *weventbox = gtk_event_box_new ();
+ /* We are not letting Gtk+ alter display on this, we only keep it here
+ so we can get it later in xg_show_toolbar_item. */
+ gtk_tool_item_set_is_important (ti, !vert_only);
+
if (wimage && ! text_image)
gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
@@ -4144,7 +4149,8 @@ xg_show_toolbar_item (GtkToolItem *ti)
int text_image = EQ (style, Qtext_image_horiz);
int horiz = both_horiz || text_image;
- int show_label = ! EQ (style, Qimage);
+ int vert_only = ! gtk_tool_item_get_is_important (ti);
+ int show_label = ! EQ (style, Qimage) && ! (vert_only && horiz);
int show_image = ! EQ (style, Qtext);
GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti));
@@ -4301,7 +4307,8 @@ update_frame_tool_bar (FRAME_PTR f)
Lisp_Object specified_file;
const char *label = (STRINGP (PROP (TOOL_BAR_ITEM_LABEL))
? SSDATA (PROP (TOOL_BAR_ITEM_LABEL)) : "");
-
+ int vert_only = ! NILP (PROP (TOOL_BAR_ITEM_VERT_ONLY));
+
ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i);
if (ti)
@@ -4391,7 +4398,7 @@ update_frame_tool_bar (FRAME_PTR f)
else
{
/* Insert an empty (non-image) button */
- ti = xg_make_tool_item (f, NULL, NULL, "", i);
+ ti = xg_make_tool_item (f, NULL, NULL, "", i, 0);
gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1);
}
continue;
@@ -4425,7 +4432,7 @@ update_frame_tool_bar (FRAME_PTR f)
}
gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
- ti = xg_make_tool_item (f, w, &wbutton, label, i);
+ ti = xg_make_tool_item (f, w, &wbutton, label, i, vert_only);
gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1);
gtk_widget_set_sensitive (wbutton, enabled_p);
}
@@ -4442,6 +4449,7 @@ update_frame_tool_bar (FRAME_PTR f)
gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage),
XG_TOOL_BAR_ICON_NAME);
gtk_label_set_text (GTK_LABEL (wlbl), label);
+ gtk_tool_item_set_is_important (ti, !vert_only);
if (stock_name &&
(! old_stock_name || strcmp (old_stock_name, stock_name) != 0))
{
diff --git a/src/keyboard.c b/src/keyboard.c
index ec5c24511c..e96d0167fd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -489,10 +489,10 @@ Lisp_Object Qconfig_changed_event;
Lisp_Object Qevent_kind;
Lisp_Object Qevent_symbol_elements;
-/* menu item parts */
+/* menu and tool bar item parts */
Lisp_Object Qmenu_enable;
Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence;
-Lisp_Object QCbutton, QCtoggle, QCradio, QClabel;
+Lisp_Object QCbutton, QCtoggle, QCradio, QClabel, QCvert_only;
/* An event header symbol HEAD may have a property named
Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
@@ -8269,9 +8269,12 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
if (NILP (menu_item_eval_property (value)))
return 0;
}
- else if (EQ (key, QChelp))
+ else if (EQ (key, QChelp))
/* `:help HELP-STRING'. */
PROP (TOOL_BAR_ITEM_HELP) = value;
+ else if (EQ (key, QCvert_only))
+ /* `:vert-only t/nil'. */
+ PROP (TOOL_BAR_ITEM_VERT_ONLY) = value;
else if (EQ (key, QClabel))
{
const char *bad_label = "!!?GARBLED ITEM?!!";
@@ -11629,6 +11632,8 @@ syms_of_keyboard (void)
staticpro (&QCradio);
QClabel = intern_c_string (":label");
staticpro (&QClabel);
+ QCvert_only = intern_c_string (":vert-only");
+ staticpro (&QCvert_only);
Qmode_line = intern_c_string ("mode-line");
staticpro (&Qmode_line);