[virt-tools-list] [virt-viewer 4/5] cleanup: Don't use stock icons

Jonathon Jongsma jjongsma at redhat.com
Tue Feb 23 17:03:43 UTC 2016


On Tue, 2016-02-23 at 15:24 +0100, Fabiano Fidêncio wrote:
> They have been deprecated since Gtk 3.10.
> ---
>  src/virt-viewer-auth.xml          |  8 ++++----
>  src/virt-viewer-guest-details.xml |  4 ++--
>  src/virt-viewer-session-spice.c   |  2 +-
>  src/virt-viewer-vm-connection.xml |  8 ++++----
>  src/virt-viewer-window.c          | 10 ++++++----
>  src/virt-viewer.xml               | 15 +++++----------
>  6 files changed, 22 insertions(+), 25 deletions(-)
> 
> diff --git a/src/virt-viewer-auth.xml b/src/virt-viewer-auth.xml
> index d307754..2920780 100644
> --- a/src/virt-viewer-auth.xml
> +++ b/src/virt-viewer-auth.xml
> @@ -24,12 +24,12 @@
>              <property name="layout_style">end</property>
>              <child>
>                <object class="GtkButton" id="button-cancel">
> -                <property name="label">gtk-cancel</property>
> +                <property name="label" translatable="yes">_Cancel</property>
>                  <property name="visible">True</property>
>                  <property name="can_focus">True</property>
>                  <property name="receives_default">True</property>
>                  <property name="use_action_appearance">False</property>
> -                <property name="use_stock">True</property>
> +                <property name="use_underline">True</property>
>                </object>
>                <packing>
>                  <property name="expand">False</property>
> @@ -39,14 +39,14 @@
>              </child>
>              <child>
>                <object class="GtkButton" id="button-ok">
> -                <property name="label">gtk-ok</property>
> +                <property name="label" translatable="yes">_OK</property>
>                  <property name="visible">True</property>
>                  <property name="can_focus">True</property>
>                  <property name="can_default">True</property>
>                  <property name="has_default">True</property>
>                  <property name="receives_default">True</property>
>                  <property name="use_action_appearance">False</property>
> -                <property name="use_stock">True</property>
> +                <property name="use_underline">True</property>
>                </object>
>                <packing>
>                  <property name="expand">False</property>
> diff --git a/src/virt-viewer-guest-details.xml b/src/virt-viewer-guest
> -details.xml
> index 7f00567..209272f 100644
> --- a/src/virt-viewer-guest-details.xml
> +++ b/src/virt-viewer-guest-details.xml
> @@ -20,11 +20,11 @@
>              <property name="layout_style">end</property>
>              <child>
>                <object class="GtkButton" id="button1">
> -                <property name="label">gtk-close</property>
> +                <property name="label" translatable="yes">_Close</property>
>                  <property name="visible">True</property>
>                  <property name="can_focus">True</property>
>                  <property name="receives_default">True</property>
> -                <property name="use_stock">True</property>
> +                <property name="use_underline">True</property>
>                </object>
>                <packing>
>                  <property name="expand">False</property>
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
> index b3fc548..dc0c1ff 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -790,7 +790,7 @@
> virt_viewer_session_spice_usb_device_selection(VirtViewerSession *session,
>      /* Create the widgets */
>      dialog = gtk_dialog_new_with_buttons(_("Select USB devices for
> redirection"), parent,
>                                           GTK_DIALOG_MODAL |
> GTK_DIALOG_DESTROY_WITH_PARENT,
> -                                         GTK_STOCK_CLOSE,
> GTK_RESPONSE_ACCEPT,
> +                                         _("_Close"), GTK_RESPONSE_ACCEPT,
>                                           NULL);
>      gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
>      gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
> diff --git a/src/virt-viewer-vm-connection.xml b/src/virt-viewer-vm
> -connection.xml
> index 62319b6..f190c92 100644
> --- a/src/virt-viewer-vm-connection.xml
> +++ b/src/virt-viewer-vm-connection.xml
> @@ -21,11 +21,11 @@
>              <property name="layout_style">end</property>
>              <child>
>                <object class="GtkButton" id="button-cancel">
> -                <property name="label">gtk-cancel</property>
> +                  <property name="label"
> translatable="yes">_Cancel</property>
>                  <property name="visible">True</property>
>                  <property name="can_focus">True</property>
>                  <property name="receives_default">True</property>
> -                <property name="use_stock">True</property>
> +                <property name="use_underline">True</property>
>                </object>
>                <packing>
>                  <property name="expand">False</property>
> @@ -35,13 +35,13 @@
>              </child>
>              <child>
>                <object class="GtkButton" id="button-connect">
> -                <property name="label">gtk-connect</property>
> +                <property name="label" translatable="yes">C_onnect</property>
>                  <property name="visible">True</property>
>                  <property name="can_focus">True</property>
>                  <property name="can_default">True</property>
>                  <property name="has_default">True</property>
>                  <property name="receives_default">True</property>
> -                <property name="use_stock">True</property>
> +                <property name="use_underline">True</property>
>                </object>
>                <packing>
>                  <property name="expand">False</property>
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 0624952..3da50fb 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -914,8 +914,8 @@ virt_viewer_window_menu_file_screenshot(GtkWidget *menu
> G_GNUC_UNUSED,
>      dialog = gtk_file_chooser_dialog_new("Save screenshot",
>                                           NULL,
>                                           GTK_FILE_CHOOSER_ACTION_SAVE,
> -                                         GTK_STOCK_CANCEL,
> GTK_RESPONSE_CANCEL,
> -                                         GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
> +                                         _("_Cancel"), GTK_RESPONSE_CANCEL,
> +                                         _("_Save"), GTK_RESPONSE_ACCEPT,
>                                           NULL);
>      gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (dialog),
> TRUE);
>      gtk_window_set_transient_for(GTK_WINDOW(dialog),
> @@ -1051,7 +1051,8 @@ virt_viewer_window_toolbar_setup(VirtViewerWindow *self)
>      gtk_toolbar_set_style(GTK_TOOLBAR(priv->toolbar),
> GTK_TOOLBAR_BOTH_HORIZ);
>  
>      /* Close connection */
> -    button = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_CLOSE));
> +    button = GTK_WIDGET(gtk_tool_button_new(NULL, NULL));
> +    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(button), "window-close");
>      gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), _("Disconnect"));
>      gtk_widget_show(GTK_WIDGET(button));
>      gtk_toolbar_insert(GTK_TOOLBAR(priv->toolbar), GTK_TOOL_ITEM (button),
> 0);
> @@ -1079,7 +1080,8 @@ virt_viewer_window_toolbar_setup(VirtViewerWindow *self)
>      priv->toolbar_send_key = button;
>  
>      /* Leave fullscreen */
> -    button =
> GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_LEAVE_FULLSCREEN));
> +    button = GTK_WIDGET(gtk_tool_button_new(NULL, NULL));
> +    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(button), "view-restore");
>      gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), _("Leave
> fullscreen"));
>      gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), _("Leave
> fullscreen"));
>      gtk_tool_item_set_is_important(GTK_TOOL_ITEM(button), TRUE);
> diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
> index 03f2f84..51afac7 100644
> --- a/src/virt-viewer.xml
> +++ b/src/virt-viewer.xml
> @@ -85,12 +85,11 @@
>                      </child>
>                      <child>
>                        <object class="GtkImageMenuItem" id="imagemenuitem5">
> -                        <property name="label">gtk-quit</property>
> +                        <property name="label"
> translatable="yes">_Quit</property>


Since we're using labels instead of stock items here, is it still necessary to
have these be GtkImageMenuItem? Or should they simply be GtkMenuItem? Several
more below.


>                          <property name="visible">True</property>
>                          <property name="can_focus">False</property>
>                          <property
> name="use_action_appearance">False</property>
>                          <property name="use_underline">True</property>
> -                        <property name="use_stock">True</property>
>                          <accelerator key="q" signal="activate"
> modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
>                          <signal name="activate"
> handler="virt_viewer_window_menu_file_quit" swapped="no"/>
>                        </object>
> @@ -137,24 +136,22 @@
>                              <child>
>                                <object class="GtkImageMenuItem" id="menu-view
> -zoom-in">
>                                  <property name="accel_path"><virt
> -viewer>/view/zoom-in</property>
> -                                <property name="label">gtk-zoom-in</property>
> +                                <property name="label"
> translatable="yes">Zoom _In</property>
>                                  <property name="visible">True</property>
>                                  <property name="can_focus">False</property>
>                                  <property
> name="use_action_appearance">False</property>
>                                  <property
> name="use_underline">True</property>
> -                                <property name="use_stock">True</property>
>                                  <signal name="activate"
> handler="virt_viewer_window_menu_view_zoom_in" swapped="no"/>
>                                </object>
>                              </child>
>                              <child>
>                                <object class="GtkImageMenuItem" id="menu-view
> -zoom-out">
>                                  <property name="accel_path"><virt
> -viewer>/view/zoom-out</property>
> -                                <property name="label">gtk-zoom
> -out</property>
> +                                <property name="label"
> translatable="yes">Zoom _Out</property>
>                                  <property name="visible">True</property>
>                                  <property name="can_focus">False</property>
>                                  <property
> name="use_action_appearance">False</property>
>                                  <property
> name="use_underline">True</property>
> -                                <property name="use_stock">True</property>
>                                  <signal name="activate"
> handler="virt_viewer_window_menu_view_zoom_out" swapped="no"/>
>                                </object>
>                              </child>
> @@ -167,12 +164,11 @@
>                              <child>
>                                <object class="GtkImageMenuItem" id="menu-view
> -zoom-reset">
>                                  <property name="accel_path"><virt
> -viewer>/view/zoom-reset</property>
> -                                <property name="label">gtk-zoom
> -100</property>
> +                                <property name="label"
> translatable="yes">_Normal Size</property>
>                                  <property name="visible">True</property>
>                                  <property name="can_focus">False</property>
>                                  <property
> name="use_action_appearance">False</property>
>                                  <property
> name="use_underline">True</property>
> -                                <property name="use_stock">True</property>
>                                  <signal name="activate"
> handler="virt_viewer_window_menu_view_zoom_reset" swapped="no"/>
>                                </object>
>                              </child>
> @@ -235,12 +231,11 @@
>                      </child>
>                      <child>
>                        <object class="GtkImageMenuItem" id="imagemenuitem10">
> -                        <property name="label">gtk-about</property>
> +                        <property name="label"
> translatable="yes">_About</property>
>                          <property name="visible">True</property>
>                          <property name="can_focus">False</property>
>                          <property
> name="use_action_appearance">False</property>
>                          <property name="use_underline">True</property>
> -                        <property name="use_stock">True</property>
>                          <signal name="activate"
> handler="virt_viewer_window_menu_help_about" swapped="no"/>
>                        </object>
>                      </child>



Since this is deprecated, we should fix it. However, I should note that this
adds a bunch more strings to the application that will need to be translated.
That may be worth mentioning in the commit log.

Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>




More information about the virt-tools-list mailing list