changeset 109566:d03bc4a3fced

Add tool bar style text-image-horiz (text to the left of the image). * lisp/cus-start.el (tool-bar-style): Add text-image-horiz. * src/gtkutil.c (xg_make_tool_item, xg_show_toolbar_item): Handle tool bar style text_image_horiz. * src/lisp.h (Qtext_image_horiz): Declare. * src/xdisp.c (Qtext_image_horiz): Define. (syms_of_xdisp): Initialize Qtext_image_horiz. Add text-image-horiz to ducumentation of tool-bar-style. * src/xsettings.c (Ftool_bar_get_system_style): Also check for Qtext_image_horiz.
author Jan D. <jan.h.d@swipnet.se>
date Wed, 28 Jul 2010 19:34:51 +0200
parents c8ed2af278ee
children 0fc9f7a0d319
files lisp/ChangeLog lisp/cus-start.el src/ChangeLog src/gtkutil.c src/lisp.h src/xdisp.c src/xsettings.c
diffstat 7 files changed, 55 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Jul 28 12:25:38 2010 +0200
+++ b/lisp/ChangeLog	Wed Jul 28 19:34:51 2010 +0200
@@ -1,3 +1,7 @@
+2010-07-28  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* cus-start.el (tool-bar-style): Add text-image-horiz.
+
 2010-07-28  Michael Albinus  <michael.albinus@gmx.de>
 
 	* progmodes/gud.el (gud-common-init): Check for remoteness of
--- a/lisp/cus-start.el	Wed Jul 28 12:25:38 2010 +0200
+++ b/lisp/cus-start.el	Wed Jul 28 19:34:51 2010 +0200
@@ -345,6 +345,7 @@
 		      (const :tag "Text" :value text)
 		      (const :tag "Both" :value both)
 		      (const :tag "Both-horiz" :value both-horiz)
+		      (const :tag "Text-image-horiz" :value text-image-horiz)
 		      (const :tag "System default" :value nil)) "23.3")
              (tool-bar-max-label-size frames integer "23.3")
 
--- a/src/ChangeLog	Wed Jul 28 12:25:38 2010 +0200
+++ b/src/ChangeLog	Wed Jul 28 19:34:51 2010 +0200
@@ -1,3 +1,17 @@
+2010-07-28  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xsettings.c (Ftool_bar_get_system_style): Also check for
+	Qtext_image_horiz.
+
+	* xdisp.c (Qtext_image_horiz): Define.
+	(syms_of_xdisp): Initialize Qtext_image_horiz.  Add text-image-horiz
+	to ducumentation of tool-bar-style.
+
+	* lisp.h (Qtext_image_horiz): Declare.
+
+	* gtkutil.c (xg_make_tool_item, xg_show_toolbar_item): Handle tool bar
+	style text_image_horiz.
+
 2010-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* emacs.c (Fkill_emacs): Remove return statement.
--- a/src/gtkutil.c	Wed Jul 28 12:25:38 2010 +0200
+++ b/src/gtkutil.c	Wed Jul 28 19:34:51 2010 +0200
@@ -3703,8 +3703,7 @@
   gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar");
 
   gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
-  toolbar_set_orientation (x->toolbar_widget,
-                               GTK_ORIENTATION_HORIZONTAL);
+  toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
 }
 
 
@@ -3749,15 +3748,23 @@
                    int i)
 {
   GtkToolItem *ti = gtk_tool_item_new ();
-  GtkWidget *vb = EQ (Vtool_bar_style, Qboth_horiz)
+  Lisp_Object style = Ftool_bar_get_system_style ();
+  int both_horiz = EQ (style, Qboth_horiz);
+  int text_image = EQ (style, Qtext_image_horiz);
+  
+  GtkWidget *vb = both_horiz || text_image
     ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
   GtkWidget *wb = gtk_button_new ();
   GtkWidget *weventbox = gtk_event_box_new ();
 
-  if (wimage)
+  if (wimage && ! text_image)
     gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
 
   gtk_box_pack_start (GTK_BOX (vb), gtk_label_new (label), TRUE, TRUE, 0);
+
+  if (wimage && text_image)
+    gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
+
   gtk_button_set_focus_on_click (GTK_BUTTON (wb), FALSE);
   gtk_button_set_relief (GTK_BUTTON (wb), GTK_RELIEF_NONE);
   gtk_container_add (GTK_CONTAINER (wb), vb);
@@ -3819,11 +3826,12 @@
 xg_show_toolbar_item (GtkToolItem *ti)
 {
   Lisp_Object style = Ftool_bar_get_system_style ();
-
-  int show_label = EQ (style, Qboth)
-    || EQ (style, Qboth_horiz) || EQ (style, Qtext);
+  int both_horiz = EQ (style, Qboth_horiz);
+  int text_image = EQ (style, Qtext_image_horiz);
+
+  int horiz = both_horiz || text_image;
+  int show_label = ! EQ (style, Qimage);
   int show_image = ! EQ (style, Qtext);
-  int horiz = EQ (style, Qboth_horiz);
 
   GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti));
   GtkWidget *wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
@@ -3836,15 +3844,21 @@
     new_box = gtk_hbox_new (FALSE, 0);
   else if (GTK_IS_HBOX (vb) && !horiz && show_label && show_image)
     new_box = gtk_vbox_new (FALSE, 0);
-  if (new_box)
+
+  if (!new_box && horiz)
+      gtk_box_reorder_child (GTK_BOX (vb), wlbl, text_image ? 0 : 1);
+  else if (new_box)
     {
       g_object_ref (G_OBJECT (wimage));
       g_object_ref (G_OBJECT (wlbl));
       gtk_container_remove (GTK_CONTAINER (vb), wimage);
       gtk_container_remove (GTK_CONTAINER (vb), wlbl);
       gtk_widget_destroy (GTK_WIDGET (vb));
-      gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
+      if (! text_image)
+        gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
       gtk_box_pack_start (GTK_BOX (new_box), wlbl, TRUE, TRUE, 0);
+      if (text_image)
+        gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0);
       gtk_container_add (GTK_CONTAINER (wbutton), new_box);
       g_object_unref (G_OBJECT (wimage));
       g_object_unref (G_OBJECT (wlbl));
--- a/src/lisp.h	Wed Jul 28 12:25:38 2010 +0200
+++ b/src/lisp.h	Wed Jul 28 19:34:51 2010 +0200
@@ -2631,7 +2631,7 @@
 extern Lisp_Object Qinhibit_redisplay, Qdisplay;
 extern Lisp_Object Qinhibit_eval_during_redisplay;
 extern Lisp_Object Qmessage_truncate_lines;
-extern Lisp_Object Qimage, Qtext, Qboth, Qboth_horiz;
+extern Lisp_Object Qimage, Qtext, Qboth, Qboth_horiz, Qtext_image_horiz;
 extern Lisp_Object Qspace, Qcenter, QCalign_to;
 extern Lisp_Object Vmessage_log_max;
 extern Lisp_Object QCdata, QCfile;
--- a/src/xdisp.c	Wed Jul 28 12:25:38 2010 +0200
+++ b/src/xdisp.c	Wed Jul 28 19:34:51 2010 +0200
@@ -456,7 +456,7 @@
 Lisp_Object Qrect, Qcircle, Qpoly;
 
 /* Tool bar styles */
-Lisp_Object Qtext, Qboth, Qboth_horiz;
+Lisp_Object Qtext, Qboth, Qboth_horiz, Qtext_image_horiz;
 
 /* Non-zero means print newline to stdout before next mini-buffer
    message.  */
@@ -25636,6 +25636,8 @@
   staticpro (&Qboth);
   Qboth_horiz = intern_c_string ("both-horiz");
   staticpro (&Qboth_horiz);
+  Qtext_image_horiz = intern_c_string ("text-image-horiz");
+  staticpro (&Qtext_image_horiz);
   QCmap = intern_c_string (":map");
   staticpro (&QCmap);
   QCpointer = intern_c_string (":pointer");
@@ -25979,11 +25981,12 @@
   DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style,
     doc: /* *Tool bar style to use.
 It can be one of
- image      - show images only
- text       - show text only
- both       - show both, text under image
- both-horiz - show text to the right of the image
- any other  - use system default or image if no system default.  */);
+ image            - show images only
+ text             - show text only
+ both             - show both, text below image
+ both-horiz       - show text to the right of the image
+ text-image-horiz - show text to the left of the image
+ any other        - use system default or image if no system default.  */);
   Vtool_bar_style = Qnil;
 
   DEFVAR_INT ("tool-bar-max-label-size", &tool_bar_max_label_size,
--- a/src/xsettings.c	Wed Jul 28 12:25:38 2010 +0200
+++ b/src/xsettings.c	Wed Jul 28 19:34:51 2010 +0200
@@ -730,7 +730,8 @@
   if (EQ (Vtool_bar_style, Qimage)
       || EQ (Vtool_bar_style, Qtext)
       || EQ (Vtool_bar_style, Qboth)
-      || EQ (Vtool_bar_style, Qboth_horiz))
+      || EQ (Vtool_bar_style, Qboth_horiz)
+      || EQ (Vtool_bar_style, Qtext_image_horiz))
     return Vtool_bar_style;
   if (!NILP (current_tool_bar_style))
     return current_tool_bar_style;