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

Fabiano Fidêncio fidencio at redhat.com
Wed Feb 24 11:03:48 UTC 2016


On Wed, Feb 24, 2016 at 9:58 AM, Pavel Grunt <pgrunt at redhat.com> wrote:
> Hi,
>
> the doc for deprecating gtk_tool_button_new_from_stock says:
>
> gtk_tool_button_new_from_stock has been deprecated since version 3.10
> and should not be used in newly-written code.
> Use gtk_tool_button_new() together with gtk_image_new_from_icon_name()
> instead.
>
> Or do you want to remove the icons ?

I don't remove the icons at all (or at least I'm not trying to).

The two places were I changed this are related to the toolbar that
shows-up when you're on fullscreen and it still shows the icons.

What I'm doing is:

button = gtk_tool_button_new(NULL, NULL);
gtk_tool_button_set_icon_name(button, "icon-name");

And I do believe it has exactly the same behavior as:

button = gtk_tool_button_new(NULL, NULL);
image = gtk_image_new_from_icon_name("icon-name", icon_size);
gtk_tool_button_set_icon_widget (button, image);


>
> Pavel
>
> On Wed, 2016-02-24 at 08:04 +0100, Fabiano Fidêncio wrote:
>> They have been deprecated since Gtk 3.10.
>>
>> As now virt-viewer uses labels instead of stock icons, a small amount
>> of
>> new strings have been added and will need to be translated.
>>
>> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
>> ---
>>  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               | 25 ++++++++++---------------
>>  6 files changed, 27 insertions(+), 30 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_SAV
>> E,
>> -                                         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..52c6c93 100644
>> --- a/src/virt-viewer.xml
>> +++ b/src/virt-viewer.xml
>> @@ -84,13 +84,12 @@
>>                        </object>
>>                      </child>
>>                      <child>
>> -                      <object class="GtkImageMenuItem"
>> id="imagemenuitem5">
>> -                        <property name="label">gtk-quit</property>
>> +                      <object class="GtkMenuItem"
>> id="imagemenuitem5">
>> +                        <property name="label"
>> translatable="yes">_Quit</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>
>>                          <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>
>> @@ -135,26 +134,24 @@
>>                              <property
>> name="can_focus">False</property>
>>                              <property
>> name="accel_group">accelgroup</property>
>>                              <child>
>> -                              <object class="GtkImageMenuItem"
>> id="menu-view-zoom-in">
>> +                              <object class="GtkMenuItem" 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">
>> +                              <object class="GtkMenuItem" 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>
>> @@ -165,14 +162,13 @@
>>                                </object>
>>                              </child>
>>                              <child>
>> -                              <object class="GtkImageMenuItem"
>> id="menu-view-zoom-reset">
>> +                              <object class="GtkMenuItem" 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>
>> @@ -234,13 +230,12 @@
>>                        </object>
>>                      </child>
>>                      <child>
>> -                      <object class="GtkImageMenuItem"
>> id="imagemenuitem10">
>> -                        <property name="label">gtk-about</property>
>> +                      <object class="GtkMenuItem"
>> id="imagemenuitem10">
>> +                        <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>




More information about the virt-tools-list mailing list