emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Icon update


From: Leon
Subject: Re: Icon update
Date: Wed, 29 Mar 2006 20:03:39 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (gnu/linux)

Can someone show me how to use this patch? I did a patch -p4 <
emacs-stokc.diff in emacs CVS dir, and it asked me for `file to
patch'. Thank you.

"Jan D." <address@hidden> writes:

> Leon wrote:
>> "Jan D." <address@hidden> writes:
>> 
>>> David Kastrup wrote:
>>>> Bill Wohler <address@hidden> writes:
>>>>
>>>>> By the way, if anyone has GTK experience, the Emacs code should be using
>>>>> the GTK libraries to render the icons and only using our built-in icons
>>>>> as a fall-back. That way, Emacs icons will pick up theme changes.
>>> I have a patch that does just that, but I decided to wait with it
>>> until after the release.  It will only work for Emacs compiled with
>>> GTK, but I guess that is obvious.
>>>
>>>     Jan D.
>> Sounds interesting. May I have a copy of the patch? Thanks.
>
> Attached.  But some icons don't have stock items, so the effect may be
> strange for some themes.
>
>       Jan D.
> Index: lisp/info.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
> retrieving revision 1.481
> diff -u -c -r1.481 info.el
> *** lisp/info.el      11 Mar 2006 22:35:18 -0000      1.481
> --- lisp/info.el      29 Mar 2006 10:05:16 -0000
> ***************
> *** 3209,3224 ****
>   (defvar info-tool-bar-map
>     (if (display-graphic-p)
>         (let ((map (make-sparse-keymap)))
> !     (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map 
> Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map 
> Info-mode-map)
>       (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
>       (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
>       (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map 
> Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
>       map)))
>   
>   (defvar Info-menu-last-node nil)
> --- 3209,3231 ----
>   (defvar info-tool-bar-map
>     (if (display-graphic-p)
>         (let ((map (make-sparse-keymap)))
> !     (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map
> !                                    :stock "gtk-close")
> !     (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map 
> Info-mode-map
> !                                    :stock "gtk-go-back")
> !     (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map 
> Info-mode-map
> !                                    :stock "gtk-go-forward")
>       (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
>       (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
>       (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
> !     (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map
> !                                    :stock "gtk-home")
> !     (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map 
> Info-mode-map
> !                                    :stock "gtk-jump-to")
> !     (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map
> !                                    :stock "gtk-index")
> !     (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map
> !                                    :stock "gtk-find")
>       map)))
>   
>   (defvar Info-menu-last-node nil)
> Index: lisp/tool-bar.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/tool-bar.el,v
> retrieving revision 1.5
> diff -u -c -r1.5 tool-bar.el
> *** lisp/tool-bar.el  6 Feb 2006 14:33:35 -0000       1.5
> --- lisp/tool-bar.el  29 Mar 2006 10:05:16 -0000
> ***************
> *** 232,279 ****
>     ;; People say it's bad to have EXIT on the tool bar, since users
>     ;; might inadvertently click that button.
>     ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
> !   (tool-bar-add-item-from-menu 'find-file "new")
> !   (tool-bar-add-item-from-menu 'menu-find-file-existing "open")
> !   (tool-bar-add-item-from-menu 'dired "diropen")
> !   (tool-bar-add-item-from-menu 'kill-this-buffer "close")
>     (tool-bar-add-item-from-menu 'save-buffer "save" nil
>                              :visible '(or buffer-file-name
>                                            (not (eq 'special
>                                                     (get major-mode
>                                                          'mode-class)))))
>     (tool-bar-add-item-from-menu 'write-file "saveas" nil
>                              :visible '(or buffer-file-name
>                                            (not (eq 'special
>                                                     (get major-mode
>                                                          'mode-class)))))
>     (tool-bar-add-item-from-menu 'undo "undo" nil
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
>                              "cut" nil
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
> !                            "copy")
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
>                              "paste" nil
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
> !   (tool-bar-add-item-from-menu 'nonincremental-search-forward "search")
>     ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
>   
>     ;; There's no icon appropriate for News and we need a command rather
>     ;; than a lambda for Read Mail.
>     ;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose")
>   
> !   (tool-bar-add-item-from-menu 'print-buffer "print")
>     (tool-bar-add-item "preferences" 'customize 'customize
>                    :help "Edit preferences (customize)")
>   
>     (tool-bar-add-item "help" (lambda ()
>                             (interactive)
>                             (popup-menu menu-bar-help-menu))
>                    'help
>                    :help "Pop up the Help menu")
>     )
>   
> --- 232,291 ----
>     ;; People say it's bad to have EXIT on the tool bar, since users
>     ;; might inadvertently click that button.
>     ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
> !   (tool-bar-add-item-from-menu 'find-file "new" nil :stock "gtk-new")
> !   (tool-bar-add-item-from-menu 'menu-find-file-existing "open"
> !                            nil :stock "gtk-open")
> !   (tool-bar-add-item-from-menu 'dired "diropen"
> !                            nil :stock "gtk-directory")
> !   (tool-bar-add-item-from-menu 'kill-this-buffer "close"
> !                            nil :stock "gtk-close")
>     (tool-bar-add-item-from-menu 'save-buffer "save" nil
> +                            :stock "gtk-save"
>                              :visible '(or buffer-file-name
>                                            (not (eq 'special
>                                                     (get major-mode
>                                                          'mode-class)))))
>     (tool-bar-add-item-from-menu 'write-file "saveas" nil
> +                            :stock "gtk-save-as"
>                              :visible '(or buffer-file-name
>                                            (not (eq 'special
>                                                     (get major-mode
>                                                          'mode-class)))))
>     (tool-bar-add-item-from-menu 'undo "undo" nil
> +                            :stock "gtk-undo"
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
>                              "cut" nil
> +                            :stock "gtk-cut"
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
> !                            "copy" nil :stock "gtk-copy")
>     (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
>                              "paste" nil
> +                            :stock "gtk-paste"
>                              :visible '(not (eq 'special (get major-mode
>                                                               'mode-class))))
> !   (tool-bar-add-item-from-menu 'nonincremental-search-forward "search"
> !                            nil :stock "gtk-find")
>     ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
>   
>     ;; There's no icon appropriate for News and we need a command rather
>     ;; than a lambda for Read Mail.
>     ;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose")
>   
> !   (tool-bar-add-item-from-menu 'print-buffer "print"
> !                            nil :stock "gtk-print")
>     (tool-bar-add-item "preferences" 'customize 'customize
> +                  :stock "gtk-preferences"
>                    :help "Edit preferences (customize)")
>   
>     (tool-bar-add-item "help" (lambda ()
>                             (interactive)
>                             (popup-menu menu-bar-help-menu))
>                    'help
> +                  :stock "gtk-help"
>                    :help "Pop up the Help menu")
>     )
>   
> Index: src/dispextern.h
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v
> retrieving revision 1.215
> diff -u -c -r1.215 dispextern.h
> *** src/dispextern.h  15 Mar 2006 07:55:36 -0000      1.215
> --- src/dispextern.h  29 Mar 2006 10:05:17 -0000
> ***************
> *** 2539,2544 ****
> --- 2539,2547 ----
>     /* Help string.  */
>     TOOL_BAR_ITEM_HELP,
>   
> +   /* Stock image.  */
> +   TOOL_BAR_ITEM_STOCK_IMAGE,
> + 
>     /* Sentinel = number of slots in tool_bar_items occupied by one
>        tool-bar item.  */
>     TOOL_BAR_ITEM_NSLOTS
> Index: src/gtkutil.c
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/gtkutil.c,v
> retrieving revision 1.84
> diff -u -c -r1.84 gtkutil.c
> *** src/gtkutil.c     24 Feb 2006 15:36:39 -0000      1.84
> --- src/gtkutil.c     29 Mar 2006 10:05:17 -0000
> ***************
> *** 3243,3248 ****
> --- 3243,3253 ----
>   #define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier"
>   
>   
> + /* The key for the data we put in the GtkImage widgets.  The data is
> +    the stock name used by Emacs.  We use this to see if we need to update
> +    the GtkImage with a new image.  */
> + #define XG_TOOL_BAR_STOCK_NAME "emacs-tool-bar-stock-name"
> + 
>   /* Callback function invoked when a tool bar item is pressed.
>      W is the button widget in the tool bar that got pressed,
>      CLIENT_DATA is an integer that is the index of the button in the
> ***************
> *** 3525,3530 ****
> --- 3530,3536 ----
>     GList *iter;
>     struct x_output *x = f->output_data.x;
>     int hmargin, vmargin;
> +   GtkToolbar *wtoolbar;
>   
>     if (! FRAME_GTK_WIDGET (f))
>       return;
> ***************
> *** 3558,3566 ****
>     if (! x->toolbar_widget)
>       xg_create_tool_bar (f);
>   
> !   gtk_widget_size_request (x->toolbar_widget, &old_req);
> ! 
> !   icon_list = gtk_container_get_children (GTK_CONTAINER 
> (x->toolbar_widget));
>     iter = icon_list;
>   
>     for (i = 0; i < f->n_tool_bar_items; ++i)
> --- 3564,3573 ----
>     if (! x->toolbar_widget)
>       xg_create_tool_bar (f);
>   
> !   wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
> !   gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req);
> !   
> !   icon_list = gtk_container_get_children (GTK_CONTAINER (wtoolbar));
>     iter = icon_list;
>   
>     for (i = 0; i < f->n_tool_bar_items; ++i)
> ***************
> *** 3571,3622 ****
>         int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
>         int idx;
>         int img_id;
> !       struct image *img;
>         Lisp_Object image;
>         GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0;
>   
>         if (iter) iter = g_list_next (iter);
>   
> !       /* If image is a vector, choose the image according to the
> !      button state.  */
> !       image = PROP (TOOL_BAR_ITEM_IMAGES);
> !       if (VECTORP (image))
> !     {
> !       if (enabled_p)
> !         idx = (selected_p
> !                ? TOOL_BAR_IMAGE_ENABLED_SELECTED
> !                : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
> !       else
> !         idx = (selected_p
> !                ? TOOL_BAR_IMAGE_DISABLED_SELECTED
> !                : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
> ! 
> !       xassert (ASIZE (image) >= idx);
> !       image = AREF (image, idx);
> !     }
> !       else
> !     idx = -1;
>   
> !       /* Ignore invalid image specifications.  */
> !       if (!valid_image_p (image))
>           {
> !           if (wicon) gtk_widget_hide (wicon);
> !           continue;
>           }
>   
> !       img_id = lookup_image (f, image);
> !       img = IMAGE_FROM_ID (f, img_id);
> !       prepare_image_for_display (f, img);
>   
> -       if (img->load_failed_p || img->pixmap == None)
> -         {
> -           if (wicon) gtk_widget_hide (wicon);
> -           continue;
>           }
>   
>         if (! wicon)
>           {
> !           GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
>             GtkToolItem *ti = gtk_tool_button_new (w, "");
>   
>             gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
> --- 3578,3663 ----
>         int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
>         int idx;
>         int img_id;
> !       int icon_size = 0;
> !       struct image *img = NULL;
>         Lisp_Object image;
> +       Lisp_Object stock;
>         GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0;
> +       GtkStockItem stock_item;
> +       char *stock_name = NULL;
>   
>         if (iter) iter = g_list_next (iter);
>   
> !       stock = PROP (TOOL_BAR_ITEM_STOCK_IMAGE);
>   
> !       if (! NILP (stock) && STRINGP (stock)
> !           && gtk_stock_lookup (SSDATA (stock), &stock_item))
>           {
> !           stock_name = SSDATA (stock);
> !           icon_size = gtk_toolbar_get_icon_size (wtoolbar);
>           }
> +       else
> +         {
> +           /* No stock image, or stock item not known.  Try regular image.  
> */
>   
> !           /* If image is a vector, choose the image according to the
> !          button state.  */
> !           image = PROP (TOOL_BAR_ITEM_IMAGES);
> !           if (VECTORP (image))
> !         {
> !           if (enabled_p)
> !             idx = (selected_p
> !                    ? TOOL_BAR_IMAGE_ENABLED_SELECTED
> !                    : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
> !           else
> !             idx = (selected_p
> !                    ? TOOL_BAR_IMAGE_DISABLED_SELECTED
> !                    : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
> !     
> !           xassert (ASIZE (image) >= idx);
> !           image = AREF (image, idx);
> !         }
> !           else
> !         idx = -1;
> ! 
> !           /* Ignore invalid image specifications.  */
> !           if (!valid_image_p (image))
> !             {
> !               if (wicon) gtk_widget_hide (wicon);
> !               continue;
> !             }
> ! 
> !           img_id = lookup_image (f, image);
> !           img = IMAGE_FROM_ID (f, img_id);
> !           prepare_image_for_display (f, img);
> ! 
> !           if (img->load_failed_p || img->pixmap == None)
> !             {
> !               if (wicon) gtk_widget_hide (wicon);
> !               continue;
> !             }
>   
>           }
>   
>         if (! wicon)
>           {
> !           GtkWidget *w;
> !           if (stock_name)
> !             {
> !               w = gtk_image_new_from_stock (stock_name, icon_size);
> !               g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_STOCK_NAME,
> !                                       (gpointer) xstrdup (stock_name),
> !                                       (GDestroyNotify) xfree);
> !             }
> !           else
> !         {
> !           w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
> !           /* Save the image so we can see if an update is needed when
> !              this function is called again.  */
> !           g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
> !                              (gpointer)img->pixmap);
> !         }
> ! 
>             GtkToolItem *ti = gtk_tool_button_new (w, "");
>   
>             gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
> ***************
> *** 3632,3641 ****
>             gtk_widget_show (GTK_WIDGET (ti));
>             gtk_widget_show (GTK_WIDGET (w));
>   
> -           /* Save the image so we can see if an update is needed when
> -              this function is called again.  */
> -           g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
> -                              (gpointer)img->pixmap);
>   
>             g_object_set_data (G_OBJECT (ti), XG_FRAME_DATA, (gpointer)f);
>   
> --- 3673,3678 ----
> ***************
> *** 3684,3698 ****
>             GtkImage *wimage = GTK_IMAGE (chlist->data);
>             Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage),
>                                                         
> XG_TOOL_BAR_IMAGE_DATA);
>             g_list_free (chlist);
>   
> !           gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin);
>   
> !           if (old_img != img->pixmap)
> !             (void) xg_get_image_for_pixmap (f, img, x->widget, wimage);
> ! 
> !           g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
> !                              (gpointer)img->pixmap);
>   
>             gtk_widget_set_sensitive (wicon, enabled_p);
>             gtk_widget_show (wicon);
> --- 3721,3751 ----
>             GtkImage *wimage = GTK_IMAGE (chlist->data);
>             Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage),
>                                                         
> XG_TOOL_BAR_IMAGE_DATA);
> +           gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage),
> +                                                        
> XG_TOOL_BAR_STOCK_NAME);
>             g_list_free (chlist);
>   
> !           if (stock_name &&
> !               (! old_stock_name || strcmp (old_stock_name, stock_name) != 
> 0))
> !             {
> !               gtk_image_set_from_stock (wimage, stock_name, icon_size);
> !               g_object_set_data_full (G_OBJECT (wimage), 
> XG_TOOL_BAR_STOCK_NAME,
> !                                       (gpointer) xstrdup (stock_name),
> !                                       (GDestroyNotify) xfree);
> !               g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
> !                                  NULL);
> !             }
> !           else if (img && old_img != img->pixmap)
> !             {
> !               (void) xg_get_image_for_pixmap (f, img, x->widget, wimage);
> !               g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
> !                                  (gpointer)img->pixmap);
> ! 
> !               g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME,
> !                                  NULL);
> !             }
>   
> !           gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin);
>   
>             gtk_widget_set_sensitive (wicon, enabled_p);
>             gtk_widget_show (wicon);
> ***************
> *** 3710,3716 ****
>         iter = g_list_next (iter);
>       }
>   
> !   gtk_widget_size_request (x->toolbar_widget, &new_req);
>     if (old_req.height != new_req.height
>         && ! FRAME_X_OUTPUT (f)->toolbar_detached)
>       {
> --- 3763,3769 ----
>         iter = g_list_next (iter);
>       }
>   
> !   gtk_widget_size_request (GTK_WIDGET (wtoolbar), &new_req);
>     if (old_req.height != new_req.height
>         && ! FRAME_X_OUTPUT (f)->toolbar_detached)
>       {
> Index: src/keyboard.c
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
> retrieving revision 1.851
> diff -u -c -r1.851 keyboard.c
> *** src/keyboard.c    29 Mar 2006 08:00:23 -0000      1.851
> --- src/keyboard.c    29 Mar 2006 10:05:18 -0000
> ***************
> *** 7573,7582 ****
>   
>   static int ntool_bar_items;
>   
> ! /* The symbols `tool-bar', and `:image'.  */
>   
>   extern Lisp_Object Qtool_bar;
>   Lisp_Object QCimage;
>   
>   /* Function prototypes.  */
>   
> --- 7573,7583 ----
>   
>   static int ntool_bar_items;
>   
> ! /* The symbols `tool-bar', `:image' and `:stock'.  */
>   
>   extern Lisp_Object Qtool_bar;
>   Lisp_Object QCimage;
> + Lisp_Object Qstock;
>   
>   /* Function prototypes.  */
>   
> ***************
> *** 7862,7867 ****
> --- 7863,7871 ----
>       /* Value is either a single image specification or a vector
>          of 4 such specifications for the different button states.  */
>       PROP (TOOL_BAR_ITEM_IMAGES) = value;
> +       else if (EQ (key, Qstock))
> +         /* ':stock STRING' */
> +     PROP (TOOL_BAR_ITEM_STOCK_IMAGE) = value;
>       }
>   
>     /* If got a filter apply it on binding.  */
> ***************
> *** 10846,10851 ****
> --- 10850,10858 ----
>     staticpro (&Qhelp_echo);
>     Qhelp_echo = intern ("help-echo");
>   
> +   staticpro (&Qstock);
> +   Qstock = intern (":stock");
> + 
>     staticpro (&item_properties);
>     item_properties = Qnil;
>   
> _______________________________________________
> Emacs-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-devel

-- 
Leon





reply via email to

[Prev in Thread] Current Thread [Next in Thread]