[sound-juicer] Remove remaining stock items



commit c3913c5a4935aa549f603a17774c5ba18a1acca5
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Wed Aug 14 12:30:10 2013 +0100

    Remove remaining stock items
    
    This removes the arrow on the 'Continue' button in the multiple album
    dialog partly to conform with the recommendation that buttons just
    have a label describing their action and partly to avoid having to
    deal with the RTL variant of the icon. The Alt+N accelerator on
    'Cancel' in the infobar is non standard but avoids a clash with the
    album composer entry. Alt+P for Pause is non standard but avoids a
    clash with the album artist entry and gives a consistent accelerator
    for Play/Pause. The disc number entry was missing an accelerator so it
    is assigned Alt+D.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705131

 data/sound-juicer.ui   |   56 +++++++++--------------------------------------
 src/egg-play-preview.c |   26 +++++++++++++--------
 src/sj-extracting.c    |   11 +++------
 src/sj-main.c          |   41 ++++++----------------------------
 src/sj-main.h          |    2 -
 src/sj-play.c          |   12 +++------
 src/sound-juicer.h     |    5 ----
 7 files changed, 43 insertions(+), 110 deletions(-)
---
diff --git a/data/sound-juicer.ui b/data/sound-juicer.ui
index f0da8c4..4886e71 100644
--- a/data/sound-juicer.ui
+++ b/data/sound-juicer.ui
@@ -92,7 +92,7 @@
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Disc:</property>
+                        <property name="label" translatable="yes">_Disc:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">disc_number_entry</property>
                         <accessibility>
@@ -325,12 +325,12 @@
                     <property name="layout_style">end</property>
                     <child>
                       <object class="GtkButton" id="play_button">
-                        <property name="label">gtk-media-play</property>
+                        <property name="label" translatable="yes">_Play</property>
+                        <property name="use-underline">True</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="can_default">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -340,12 +340,12 @@
                     </child>
                     <child>
                       <object class="GtkButton" id="extract_button">
-                        <property name="label">sj-stock-extract</property>
+                        <property name="label" translatable="yes">E_xtract</property>
+                        <property name="use-underline">True</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="can_default">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_stock">True</property>
                         <signal name="clicked" handler="on_extract_activate"/>
                       </object>
                       <packing>
@@ -536,46 +536,12 @@ audio-volume-medium</property>
             <child>
               <object class="GtkButton" id="ok_button">
                 <property name="visible">True</property>
+                <property name="label" translatable="yes">_Continue</property>
+                <property name="use_underline">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">False</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment2">
-                    <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox2">
-                        <property name="visible">True</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkImage" id="image16">
-                            <property name="visible">True</property>
-                            <property name="stock">gtk-go-forward</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label11">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">_Continue</property>
-                            <property name="use_underline">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -1018,12 +984,12 @@ audio-volume-medium</property>
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="prefs_help">
-                <property name="label">gtk-help</property>
+                <property name="label" translatable="yes">_Help</property>
+                <property name="use_underline">True</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -1033,12 +999,12 @@ audio-volume-medium</property>
             </child>
             <child>
               <object class="GtkButton" id="prefs_close">
-                <property name="label">gtk-close</property>
+                <property name="label" translatable="yes">_Close</property>
+                <property name="use_underline">True</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/src/egg-play-preview.c b/src/egg-play-preview.c
index 9c664d6..dd37808 100644
--- a/src/egg-play-preview.c
+++ b/src/egg-play-preview.c
@@ -67,6 +67,8 @@ struct _EggPlayPreviewPrivate {
        GstElement *playbin;
        GstState state;
 
+       gchar *play_icon_name;
+
        gchar *title;
        gchar *artist;
        gchar *album;
@@ -278,7 +280,11 @@ egg_play_preview_init (EggPlayPreview *play_preview)
 
        /* play button */
        priv->play_button = gtk_button_new ();
-       priv->play_button_image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
+       if (gtk_widget_get_direction (GTK_WIDGET (priv->play_button)) == GTK_TEXT_DIR_RTL)
+           priv->play_icon_name = "media-playback-start-rtl";
+       else
+           priv->play_icon_name = "media-playback-start";
+       priv->play_button_image = gtk_image_new_from_icon_name (priv->play_icon_name, GTK_ICON_SIZE_BUTTON);
        gtk_container_add (GTK_CONTAINER (priv->play_button), priv->play_button_image);
        align = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
        gtk_container_add (GTK_CONTAINER (align), priv->play_button);
@@ -751,9 +757,9 @@ _play (EggPlayPreview *play_preview)
 
        gst_element_set_state (priv->playbin, GST_STATE_PLAYING);
 
-       gtk_image_set_from_stock (GTK_IMAGE (priv->play_button_image),
-                                                         GTK_STOCK_MEDIA_PAUSE,
-                                                         GTK_ICON_SIZE_BUTTON);
+       gtk_image_set_from_icon_name (GTK_IMAGE (priv->play_button_image),
+                                     "media-playback-pause",
+                                     GTK_ICON_SIZE_BUTTON);
 }
 
 static void
@@ -765,9 +771,9 @@ _pause (EggPlayPreview *play_preview)
 
        gst_element_set_state (priv->playbin, GST_STATE_PAUSED);
 
-       gtk_image_set_from_stock (GTK_IMAGE (priv->play_button_image),
-                                                         GTK_STOCK_MEDIA_PLAY,
-                                                         GTK_ICON_SIZE_BUTTON);
+       gtk_image_set_from_icon_name (GTK_IMAGE (priv->play_button_image),
+                                     priv->play_icon_name,
+                                     GTK_ICON_SIZE_BUTTON);
 }
 
 static void
@@ -779,9 +785,9 @@ _stop (EggPlayPreview *play_preview)
 
        gst_element_set_state (priv->playbin, GST_STATE_READY);
 
-       gtk_image_set_from_stock (GTK_IMAGE (priv->play_button_image),
-                                                         GTK_STOCK_MEDIA_PLAY,
-                                                         GTK_ICON_SIZE_BUTTON);
+       gtk_image_set_from_icon_name (GTK_IMAGE (priv->play_button_image),
+                                     priv->play_icon_name,
+                                     GTK_ICON_SIZE_BUTTON);
 }
 
 GtkWidget *
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index ae8ee93..08d7974 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -230,9 +230,8 @@ cleanup (void)
   }
   /* Forcibly invalidate the iterator */
   current.stamp = 0;
-  /* TODO: find out why GTK+ needs this to work (see #364371) */
-  gtk_button_set_label (GTK_BUTTON (extract_button), _("Extract"));
-  gtk_button_set_label (GTK_BUTTON (extract_button), SJ_STOCK_EXTRACT);
+
+  gtk_button_set_label (GTK_BUTTON (extract_button), _("E_xtract"));
 
   /* Clear the Status bar */
   gtk_statusbar_push (GTK_STATUSBAR (status_bar), 0, "");
@@ -456,7 +455,7 @@ pop_and_extract (int *overwrite_mode)
     /* OK, we can write/overwrite the file */
 
 
-    /* Update the state stock image */
+    /* Update the state image */
     gtk_list_store_set (track_store, &current,
                    COLUMN_STATE, STATE_EXTRACTING, -1);
 
@@ -792,9 +791,7 @@ on_extract_activate (GtkWidget *button, gpointer user_data)
   }
 
   /* Change the label to Stop while extracting*/
-  /* TODO: find out why GTK+ needs this to work (see #364371) */
-  gtk_button_set_label (GTK_BUTTON (extract_button), _("Stop"));
-  gtk_button_set_label (GTK_BUTTON (extract_button), GTK_STOCK_STOP);
+  gtk_button_set_label (GTK_BUTTON (extract_button), _("_Stop"));
   gtk_widget_show (progress_bar);
 
   /* Reset the progress dialog */
diff --git a/src/sj-main.c b/src/sj-main.c
index ea67637..d3ab735 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -113,31 +113,6 @@ static guint debug_flags = 0;
 #define COMPOSER_ROW 2 /* Row of entry_table containing composer_entry */
 
 void
-sj_stock_init (void)
-{
-  static gboolean initialized = FALSE;
-  static GtkIconFactory *sj_icon_factory = NULL;
-
-  static const GtkStockItem sj_stock_items[] =
-  {
-    { SJ_STOCK_EXTRACT, N_("E_xtract"), GDK_CONTROL_MASK, GDK_KEY_Return, NULL }
-  };
-
-  if (initialized)
-    return;
-
-  sj_icon_factory = gtk_icon_factory_new ();
-
-  gtk_icon_factory_add (sj_icon_factory, SJ_STOCK_EXTRACT, gtk_icon_factory_lookup_default 
(GTK_STOCK_CDROM));
-
-  gtk_icon_factory_add_default (sj_icon_factory);
-
-  gtk_stock_add_static (sj_stock_items, G_N_ELEMENTS (sj_stock_items));
-
-  initialized = TRUE;
-}
-
-void
 sj_main_set_title (const char* detail)
 {
   if (detail == NULL) {
@@ -345,7 +320,7 @@ static void number_cell_icon_data_cb (GtkTreeViewColumn *tree_column,
 /* Taken from gedit */
 static void
 set_info_bar_text_and_icon (GtkInfoBar  *infobar,
-                            const gchar *icon_stock_id,
+                            const gchar *icon_name,
                             const gchar *primary_text,
                             const gchar *secondary_text,
                             GtkWidget   *button)
@@ -365,7 +340,7 @@ set_info_bar_text_and_icon (GtkInfoBar  *infobar,
   hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8); 
   gtk_widget_show (hbox_content);
 
-  image = gtk_image_new_from_stock (icon_stock_id, GTK_ICON_SIZE_DIALOG);
+  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
   gtk_widget_show (image);
   gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
   gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
@@ -440,13 +415,13 @@ musicbrainz_submit_info_bar_new (char *title, char *artist)
   button = gtk_info_bar_add_button (GTK_INFO_BAR (infobar),
                                     _("S_ubmit Album"), GTK_RESPONSE_OK);
   gtk_info_bar_add_button (GTK_INFO_BAR (infobar),
-                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+                           _("Ca_ncel"), GTK_RESPONSE_CANCEL);
 
   /* Translators: title, artist */
   primary_text = g_strdup_printf (_("Could not find %s by %s on MusicBrainz."), title, artist);
 
   set_info_bar_text_and_icon (GTK_INFO_BAR (infobar),
-                              "gtk-dialog-info",
+                              "dialog-information",
                               primary_text,
                               _("You can improve the MusicBrainz database by adding this album."),
                               button);
@@ -2169,13 +2144,15 @@ startup_cb (GApplication *app, gpointer user_data)
 
     size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
-    fake_button1 = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
+    fake_button1 = gtk_button_new_with_label (_("_Play"));
+    gtk_button_set_use_underline (GTK_BUTTON (fake_button1), TRUE);
     gtk_size_group_add_widget (size_group, fake_button1);
     g_signal_connect_swapped (play_button, "destroy",
                               G_CALLBACK (gtk_widget_destroy),
                               fake_button1);
 
-    fake_button2 = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE);
+    fake_button2 = gtk_button_new_with_label (_("_Pause"));
+    gtk_button_set_use_underline (GTK_BUTTON (fake_button2), TRUE);
     gtk_size_group_add_widget (size_group, fake_button2);
     g_signal_connect_swapped (play_button, "destroy",
                               G_CALLBACK (gtk_widget_destroy),
@@ -2446,8 +2423,6 @@ int main (int argc, char **argv)
 
   sj_debug_init ();
 
-  sj_stock_init ();
-
   gtk_window_set_default_icon_name ("sound-juicer");
 
   app = gtk_application_new ("org.gnome.sound-juicer",
diff --git a/src/sj-main.h b/src/sj-main.h
index c580f98..a40d7f6 100644
--- a/src/sj-main.h
+++ b/src/sj-main.h
@@ -24,8 +24,6 @@
 #include <gtk/gtk.h>
 #include "sj-structures.h"
 
-void sj_stock_init (void);
-
 void set_action_enabled (const char *name, gboolean enabled);
 
 G_MODULE_EXPORT void on_destroy_activate (GtkMenuItem *item, gpointer user_data);
diff --git a/src/sj-play.c b/src/sj-play.c
index d6fbac9..1deff8c 100644
--- a/src/sj-play.c
+++ b/src/sj-play.c
@@ -119,7 +119,7 @@ _stop (void)
   gtk_widget_hide (volume_button);
   sj_main_set_title (NULL);
   gtk_statusbar_push (GTK_STATUSBAR (statusbar), 0, "");
-  gtk_button_set_label (GTK_BUTTON (play_button), GTK_STOCK_MEDIA_PLAY);
+  gtk_button_set_label (GTK_BUTTON (play_button), _("_Play"));
   slen = GST_CLOCK_TIME_NONE;
 
   if (current_track != -1 &&
@@ -257,9 +257,7 @@ cb_change_button (gpointer data)
 {
   button_change_id = 0;
 
-  /* TODO: find out why GTK+ needs this to work (see #364371) */
-  gtk_button_set_label (GTK_BUTTON (data), _("Play"));
-  gtk_button_set_label (GTK_BUTTON (data), GTK_STOCK_MEDIA_PLAY);
+  gtk_button_set_label (GTK_BUTTON (data), _("_Play"));
 
   /* once */
   return FALSE;
@@ -301,9 +299,7 @@ cb_state (GstBus *bus, GstMessage *message, gpointer user_data)
     gtk_statusbar_push (GTK_STATUSBAR (statusbar), 0, "");
     current_track = -1;
   } else if (transition == GST_STATE_CHANGE_PAUSED_TO_PLAYING) {
-    /* TODO: find out why GTK+ needs this to work (see #364371) */
-    gtk_button_set_label (GTK_BUTTON (play_button), _("Pause"));
-    gtk_button_set_label (GTK_BUTTON (play_button), GTK_STOCK_MEDIA_PAUSE);
+    gtk_button_set_label (GTK_BUTTON (play_button), _("_Pause"));
     if (id)
       g_source_remove (id);
     id = g_timeout_add (100, (GSourceFunc) cb_set_time, NULL);
@@ -607,7 +603,7 @@ on_seek_release (GtkWidget * scale, GdkEvent * event, gpointer user_data)
 void
 stop_ui_hack (void)
 {
-  gtk_button_set_label (GTK_BUTTON (play_button), GTK_STOCK_MEDIA_PLAY);
+  gtk_button_set_label (GTK_BUTTON (play_button), _("_Play"));
   gtk_widget_hide (seek_scale);
   gtk_widget_hide (volume_button);
   gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
diff --git a/src/sound-juicer.h b/src/sound-juicer.h
index bc45f55..a91dad9 100644
--- a/src/sound-juicer.h
+++ b/src/sound-juicer.h
@@ -163,11 +163,6 @@ void sj_debug (SjDebugDomain domain, const gchar* format, ...);
 #define GCONF_HTTP_PROXY GCONF_PROXY_ROOT "/host"
 #define GCONF_HTTP_PROXY_PORT GCONF_PROXY_ROOT "/port"
 
-/**
- * Custom stock icons
- */
-#define SJ_STOCK_EXTRACT "sj-stock-extract"
-
 /* TODO: need to add a SjWindow object or something */
 void sj_main_set_title (const char* detail);
 


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