[Xfce4-commits] [apps/xfmpc] 02/03: Fix (most) GTK+3 deprecations

noreply at xfce.org noreply at xfce.org
Sat Feb 23 20:11:12 CET 2019


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfmpc.

commit 34df965887ad1bdaf09c7057e3ececbc99392a0f
Author: Johannes Marbach <n0-0ne+xfce at mailbox.org>
Date:   Fri Feb 15 22:12:50 2019 +0100

    Fix (most) GTK+3 deprecations
---
 src/dbbrowser.vala          |  65 +++++++++++++---------------
 src/extended-interface.vala |  42 +++++-------------
 src/interface.vala          |  19 +++++----
 src/main-window.vala        |   4 +-
 src/mpdclient.c             |  16 +++----
 src/playlist.vala           |  25 ++++++-----
 src/preferences-dialog.vala |  53 +++++++++++++----------
 src/shortcuts-dialog.vala   |  20 ++++++---
 src/song-dialog.vala        |   2 +-
 src/xfce-arrow-button.c     | 101 ++++++++++++++++++++++++++++----------------
 10 files changed, 183 insertions(+), 164 deletions(-)

diff --git a/src/dbbrowser.vala b/src/dbbrowser.vala
index 6893794..d27a808 100644
--- a/src/dbbrowser.vala
+++ b/src/dbbrowser.vala
@@ -21,7 +21,7 @@ using Gtk;
 
 namespace Xfmpc {
 
-	public class Dbbrowser : VBox {
+	public class Dbbrowser : Box {
 
 		private unowned Xfmpc.Mpdclient mpdclient;
 		private unowned Xfmpc.Preferences preferences;
@@ -30,7 +30,7 @@ namespace Xfmpc {
 		private Gtk.TreeView treeview;
 		private Gtk.Menu menu;
 		private Gtk.Entry search_entry;
-		private Gtk.ImageMenuItem mi_browse;
+		private Gtk.MenuItem mi_browse;
 
 		private string wdir;
 		private string last_wdir;
@@ -55,6 +55,8 @@ namespace Xfmpc {
 			this.wdir = "";
 			this.last_wdir = "";
 
+			set_orientation (Gtk.Orientation.VERTICAL);
+
 			this.store = new Gtk.ListStore (Columns.N_COLUMNS,
 					       	    	typeof (int),
 					       	    	typeof (Gdk.Pixbuf),
@@ -69,7 +71,6 @@ namespace Xfmpc {
   			this.treeview.set_enable_search (true);
 			this.treeview.set_search_column (Columns.COLUMN_BASENAME);
 			this.treeview.set_headers_visible (false);
-			this.treeview.set_rules_hint (true);
 			this.treeview.set_model (this.store);
 
 			var cell_pixbuf = new Gtk.CellRendererPixbuf ();
@@ -89,24 +90,20 @@ namespace Xfmpc {
 
 			this.menu = new Gtk.Menu ();
 
-			var mi = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.ADD, null);
+			var mi = new Gtk.MenuItem.with_mnemonic (_("Add"));
 			this.menu.append (mi);
 			mi.activate.connect (add_selected_rows);
-			mi = new Gtk.ImageMenuItem.with_mnemonic (_("Replace"));
-			var image = new Gtk.Image.from_stock (Gtk.Stock.CUT, Gtk.IconSize.MENU);
-			mi.set_image (image);
+			mi = new Gtk.MenuItem.with_mnemonic (_("Replace"));
 			this.menu.append (mi);
 			mi.activate.connect (cb_replace_with_selected_rows);
-			this.mi_browse = new Gtk.ImageMenuItem.with_mnemonic (_("Browse"));
-			image = new Gtk.Image.from_stock (Gtk.Stock.OPEN, Gtk.IconSize.MENU);
-			this.mi_browse.set_image (image);
+			this.mi_browse = new Gtk.MenuItem.with_mnemonic (_("Browse"));
 			this.menu.append (this.mi_browse);
 			this.mi_browse.activate.connect (cb_browse);
 
 			this.menu.show_all ();
 
 			this.search_entry = new Entry ();
-			this.search_entry.set_icon_from_stock (EntryIconPosition.PRIMARY, Gtk.Stock.FIND);
+			this.search_entry.set_icon_from_icon_name (EntryIconPosition.PRIMARY, "edit-find");
 			this.search_entry.set_icon_activatable (EntryIconPosition.PRIMARY, false);
 			this.search_entry.set_icon_activatable (EntryIconPosition.SECONDARY, true);
 
@@ -181,8 +178,9 @@ namespace Xfmpc {
 		public void append (string filename, string basename, bool is_dir, bool is_bold) {
 			Gtk.TreeIter iter;
 
-			var pixbuf = this.treeview.render_icon (is_dir ? Gtk.Stock.DIRECTORY : Gtk.Stock.FILE,
-					                        Gtk.IconSize.MENU, null);
+			var pixbuf = Gtk.IconTheme.get_default ()
+				.load_icon(is_dir ? "folder" : "text-x-generic",
+					   Gtk.IconSize.MENU, 0);
 
 			this.store.append (out iter);
 			this.store.set (iter,
@@ -236,11 +234,8 @@ namespace Xfmpc {
 
 			bool no_result_buf = false, no_result = false;
 
-			Gdk.Color color;
-			Gdk.Color.parse ("white", out color);
-			color.red = 0xFFFF;
-			color.green = 0x6666;
-			color.blue = 0x6666;
+			var color = new Gdk.RGBA ();
+			color.parse ("#F66");
 
 			if (i == 0)
 				no_result = true;
@@ -251,30 +246,30 @@ namespace Xfmpc {
 #if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
 				this.search_entry.modify_base (Gtk.StateType.NORMAL, color);
 #endif
-				this.search_entry.modify_bg (Gtk.StateType.NORMAL, color);
-				this.search_entry.modify_bg (Gtk.StateType.SELECTED, color);
+				this.search_entry.override_background_color (Gtk.StateFlags.NORMAL, color);
+				this.search_entry.override_background_color (Gtk.StateFlags.SELECTED, color);
 			}
 			else if (no_result == no_result_buf && !no_result) {
 #if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
-				this.search_entry.modify_base (Gtk.StateType.NORMAL, null);
+				this.search_entry.modify_base (Gtk.StateFlags.NORMAL, null);
 #endif
-				this.search_entry.modify_bg (Gtk.StateType.NORMAL, null);
-				this.search_entry.modify_bg (Gtk.StateType.SELECTED, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.NORMAL, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.SELECTED, null);
 			}
 
 			if (i == 0) {
 #if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
-      				this.search_entry.modify_base (Gtk.StateType.NORMAL, color);
+      				this.search_entry.modify_base (Gtk.StateFlags.NORMAL, color);
 #endif
-				this.search_entry.modify_bg (Gtk.StateType.NORMAL, color);
-				this.search_entry.modify_bg (Gtk.StateType.SELECTED, color);
+				this.search_entry.override_background_color (Gtk.StateFlags.NORMAL, color);
+				this.search_entry.override_background_color (Gtk.StateFlags.SELECTED, color);
 			}
 			else if (no_result) {
 #if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
-      				this.search_entry.modify_base (Gtk.StateType.NORMAL, null);
+      				this.search_entry.modify_base (Gtk.StateFlags.NORMAL, null);
 #endif
-				this.search_entry.modify_bg (Gtk.StateType.NORMAL, null);
-				this.search_entry.modify_bg (Gtk.StateType.SELECTED, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.NORMAL, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.SELECTED, null);
 			}
 		}
 
@@ -293,7 +288,7 @@ namespace Xfmpc {
 			else
 				this.mi_browse.hide ();
 
-			this.menu.popup (null, null, null, 0, get_current_event_time ());
+			this.menu.popup_at_pointer (null);
 		}
 
 		/*
@@ -440,10 +435,10 @@ namespace Xfmpc {
 
       	      	      	      	/* revert possible previous applied color */
 #if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
-				this.search_entry.modify_base (Gtk.StateType.NORMAL, null);
+				this.search_entry.modify_base (Gtk.StateFlags.NORMAL, null);
 #endif
-				this.search_entry.modify_bg (Gtk.StateType.NORMAL, null);
-				this.search_entry.modify_bg (Gtk.StateType.SELECTED, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.NORMAL, null);
+				this.search_entry.override_background_color (Gtk.StateFlags.SELECTED, null);
 
 				return;
 			}
@@ -464,10 +459,10 @@ namespace Xfmpc {
 
 		private void cb_search_entry_changed () {
 			if (search_entry.get_text () != "") {
-				search_entry.set_icon_from_stock (EntryIconPosition.SECONDARY, Gtk.Stock.CLEAR);
+				search_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, "edit-clear");
 			}
 			else {
-				search_entry.set_icon_from_stock (EntryIconPosition.SECONDARY, null);
+				search_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, null);
 			}
 
 			if (this.search_timeout > 0)
diff --git a/src/extended-interface.vala b/src/extended-interface.vala
index d82c2f2..8cc1687 100644
--- a/src/extended-interface.vala
+++ b/src/extended-interface.vala
@@ -21,7 +21,7 @@ using Gtk;
 
 namespace Xfmpc {
 
-	public class ExtendedInterface : VBox {
+	public class ExtendedInterface : Box {
 
 		private unowned Xfmpc.Mpdclient mpdclient;
 		private unowned Xfmpc.Preferences preferences;
@@ -52,6 +52,8 @@ namespace Xfmpc {
 			this.mpdclient = Xfmpc.Mpdclient.get_default ();
 			this.preferences = Xfmpc.Preferences.get_default ();
 
+			set_orientation (Gtk.Orientation.VERTICAL);
+
 			var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
 			pack_start (hbox, false, false, 2);
 
@@ -60,7 +62,7 @@ namespace Xfmpc {
 			button.clicked.connect (cb_playlist_clear);
 			hbox.pack_start (button, false, false, 0);
 
-			var image = new Gtk.Image.from_stock (Gtk.Stock.NEW, Gtk.IconSize.MENU);
+			var image = new Gtk.Image.from_icon_name ("document-new", Gtk.IconSize.MENU);
 			button.set_image (image);
 
 			button = new Gtk.Button ();
@@ -68,7 +70,7 @@ namespace Xfmpc {
 			button.clicked.connect (cb_database_refresh);
 			hbox.pack_start (button, false, false, 0);
 
-			image = new Gtk.Image.from_stock (Gtk.Stock.REFRESH, Gtk.IconSize.MENU);
+			image = new Gtk.Image.from_icon_name ("view-refresh", Gtk.IconSize.MENU);
 			button.set_image (image);
 
 			this.context_button = new Xfce.ArrowButton (Gtk.ArrowType.DOWN);
@@ -134,32 +136,10 @@ namespace Xfmpc {
 			this.single.set_active (this.mpdclient.get_single ());
 			this.consume.set_active (this.mpdclient.get_consume ());
 
-			this.context_menu.popup (null, null,
-					    (Gtk.MenuPositionFunc) this.position_context_menu,
-					    0, get_current_event_time ());
-		}
-
-		private static void position_context_menu (Gtk.Menu menu, int x, int y, bool push_in) {
-			Gtk.Allocation allocation;
-			int root_x;
-			int root_y;
-			int pref_height;
-
-			menu.get_preferred_height (null, out pref_height);
-			(((Gtk.Widget) context_button).get_window ()).get_origin (out root_x, out root_y);
-			((Gtk.Widget) context_button).get_allocation (out allocation);
-
-			x = root_x + allocation.x;
-			y = root_y + allocation.y;
-			x = 0;
-			y = 0;
-
-			if (y > Gdk.Screen.height () - pref_height)
-				y = Gdk.Screen.height () - pref_height;
-			else if (y < 0)
-				y = 0;
-
-			push_in = false;
+			this.context_menu.popup_at_widget ((Gtk.Widget) this.context_button,
+							   Gdk.Gravity.SOUTH_WEST,
+							   Gdk.Gravity.NORTH_WEST,
+							   null);
 		}
 
 		private void context_menu_new (Gtk.Widget attach_widget) {
@@ -187,7 +167,7 @@ namespace Xfmpc {
 			var separator = new Gtk.SeparatorMenuItem ();
 			this.context_menu.append (separator);
 
-			var imi = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.PREFERENCES, null);
+			var imi = new Gtk.MenuItem.with_mnemonic (_("_Preferences"));
 			imi.activate.connect (cb_preferences);
 			this.context_menu.append (imi);
 
@@ -195,7 +175,7 @@ namespace Xfmpc {
 			mi.activate.connect (cb_shortcuts);
 			this.context_menu.append (mi);
 
-			imi = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.ABOUT, null);
+			imi = new Gtk.MenuItem.with_mnemonic (_("_About"));
 			imi.activate.connect (cb_about);
 			this.context_menu.append (imi);
 
diff --git a/src/interface.vala b/src/interface.vala
index a942e58..4918cd3 100644
--- a/src/interface.vala
+++ b/src/interface.vala
@@ -21,7 +21,7 @@ using Gtk;
 
 namespace Xfmpc {
 
-	public class Interface : VBox {
+	public class Interface : Box {
 
 		private unowned Xfmpc.Mpdclient mpdclient;
 		private unowned Xfmpc.Preferences preferences;
@@ -40,19 +40,20 @@ namespace Xfmpc {
 			this.mpdclient = Xfmpc.Mpdclient.get_default ();
 			this.preferences = Xfmpc.Preferences.get_default ();
 
+			set_orientation (Gtk.Orientation.VERTICAL);
 			set_border_width (4);
 
-			var image = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_PREVIOUS, Gtk.IconSize.BUTTON);
+			var image = new Gtk.Image.from_icon_name ("media-skip-backward", Gtk.IconSize.BUTTON);
 			this.button_prev = new Gtk.Button ();
 			this.button_prev.set_relief (Gtk.ReliefStyle.NONE);
 			this.button_prev.add (image);
 
-			image = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_PLAY, Gtk.IconSize.BUTTON);
+			image = new Gtk.Image.from_icon_name ("media-playback-start", Gtk.IconSize.BUTTON);
 			this.button_pp = new Gtk.Button ();
 			this.button_pp.set_relief (Gtk.ReliefStyle.NONE);
 			this.button_pp.add (image);
 
-			image = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_NEXT, Gtk.IconSize.BUTTON);
+			image = new Gtk.Image.from_icon_name ("media-skip-forward", Gtk.IconSize.BUTTON);
 			this.button_next = new Gtk.Button ();
 			this.button_next.set_relief (Gtk.ReliefStyle.NONE);
 			this.button_next.add (image);
@@ -86,7 +87,8 @@ namespace Xfmpc {
 			title.set_attributes (attrs);
 			title.set_selectable (true);
 			title.set_ellipsize (Pango.EllipsizeMode.END);
-			title.set_alignment (0, (float) 0.5);
+			title.xalign = 0.0f;
+			title.yalign = 0.5f;
 
   	  	  	/* Subtitle */
 			attrs = new Pango.AttrList ();
@@ -99,7 +101,8 @@ namespace Xfmpc {
 			this.subtitle.set_attributes (attrs);
 			this.subtitle.set_selectable (true);
 			this.subtitle.set_ellipsize (Pango.EllipsizeMode.END);
-			this.subtitle.set_alignment (0, (float) 0.5);
+			this.subtitle.xalign = 0.0f;
+			this.subtitle.yalign = 0.5f;
 
   	  	  	/* === Containers === */
 			var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
@@ -151,9 +154,9 @@ namespace Xfmpc {
 			var image = (Gtk.Image) this.button_pp.get_child ();
 
 			if (play == true)
-				image.set_from_stock (Gtk.Stock.MEDIA_PAUSE, Gtk.IconSize.BUTTON);
+				image.set_from_icon_name ("media-playback-pause", Gtk.IconSize.BUTTON);
 			else
-				image.set_from_stock (Gtk.Stock.MEDIA_PLAY, Gtk.IconSize.BUTTON);
+				image.set_from_icon_name ("media-playback-start", Gtk.IconSize.BUTTON);
 		}
 
 		private bool cb_progress_box_motion_event (Gdk.EventMotion event) {
diff --git a/src/main-window.vala b/src/main-window.vala
index a54ecfa..5079c94 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -96,7 +96,7 @@ namespace Xfmpc {
 			this.vbox.pack_start (this. at interface, false, false, 4);
 
   	  	  	/* Separator */
-			var separator = new Gtk.HSeparator ();
+			var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
 			this.vbox.pack_start (separator, false, false, 0);
 
   	  	  	/* ExtendedInterface */
@@ -151,7 +151,7 @@ namespace Xfmpc {
 		private void status_icon_popup_menu (uint button, uint activate_time) {
 			if (this.status_icon_menu == null) {
 				this.status_icon_menu = new Gtk.Menu ();
-				var mi = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.QUIT, null);
+				var mi = new Gtk.MenuItem.with_mnemonic (_("Quit"));
 				mi.activate.connect (Gtk.main_quit);
 				this.status_icon_menu.add (mi);
 				this.status_icon_menu.show_all ();
diff --git a/src/mpdclient.c b/src/mpdclient.c
index cdcd74b..61ffcee 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -106,7 +106,7 @@ struct _XfmpcMpdclientPrivate
   gboolean                  env_cached;
   gboolean                  connecting;
   guint                     connection_count;
-  GMutex                   *mutex;
+  GMutex                    mutex;
 };
 
 
@@ -274,9 +274,7 @@ xfmpc_mpdclient_init (XfmpcMpdclient *mpdclient)
   XfmpcMpdclientPrivate *priv = mpdclient->priv = GET_PRIVATE (mpdclient);
 
   priv->mi = mpd_new_default ();
-
-  if (!g_thread_supported ()) g_thread_init (NULL);
-  priv->mutex = g_mutex_new ();
+  g_mutex_init (&priv->mutex);
 
   mpd_signal_connect_status_changed (priv->mi, (StatusChangedCallback)cb_status_changed, mpdclient);
 }
@@ -288,7 +286,7 @@ xfmpc_mpdclient_finalize (GObject *object)
   XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
 
   mpd_free (priv->mi);
-  g_mutex_free (priv->mutex);
+  g_mutex_clear (&priv->mutex);
 
   (*G_OBJECT_CLASS (parent_class)->finalize) (object);
 }
@@ -403,7 +401,7 @@ xfmpc_mpdclient_connect (XfmpcMpdclient *mpdclient)
     return TRUE;
 
   /* return FALSE if a we are already trying to connect to mpd */
-  if (!g_mutex_trylock (priv->mutex))
+  if (!g_mutex_trylock (&priv->mutex))
   {
     g_warning ("Already connecting to mpd");
     return FALSE;
@@ -411,8 +409,8 @@ xfmpc_mpdclient_connect (XfmpcMpdclient *mpdclient)
 
   priv->connecting = TRUE;
 
-  thread = g_thread_create ((GThreadFunc) xfmpc_mpdclient_connect_thread,
-          mpdclient, TRUE, NULL);
+  thread = g_thread_new ("connection thread", (GThreadFunc) xfmpc_mpdclient_connect_thread,
+          mpdclient);
 
   while (priv->connecting)
   {
@@ -425,7 +423,7 @@ xfmpc_mpdclient_connect (XfmpcMpdclient *mpdclient)
 
   g_signal_emit (mpdclient, signals[SIG_CONNECTED], 0);
 
-  g_mutex_unlock (priv->mutex);
+  g_mutex_unlock (&priv->mutex);
 
   return TRUE;
 }
diff --git a/src/playlist.vala b/src/playlist.vala
index 1ed9a5e..fe65df2 100644
--- a/src/playlist.vala
+++ b/src/playlist.vala
@@ -21,7 +21,7 @@ using Gtk;
 
 namespace Xfmpc {
 
-	public class Playlist : VBox {
+	public class Playlist : Box {
 
 		private unowned Xfmpc.Mpdclient mpdclient;
 		private unowned Xfmpc.Preferences preferences;
@@ -32,8 +32,8 @@ namespace Xfmpc {
 		private Gtk.Menu menu;
 		private static Gtk.Entry filter_entry;
 
-		private Gtk.ImageMenuItem mi_browse;
-		private Gtk.ImageMenuItem mi_information;
+		private Gtk.MenuItem mi_browse;
+		private Gtk.MenuItem mi_information;
 
 		private int current = 0;
 		private bool autocenter;
@@ -52,6 +52,8 @@ namespace Xfmpc {
 			this.mpdclient = Xfmpc.Mpdclient.get_default ();
 			this.preferences = Xfmpc.Preferences.get_default ();
 
+			set_orientation (Gtk.Orientation.VERTICAL);
+
 			this.autocenter = this.preferences.playlist_autocenter;
 
 			this.store = new Gtk.ListStore (Columns.N_COLUMNS,
@@ -70,7 +72,6 @@ namespace Xfmpc {
 			this.treeview.set_rubber_banding (true);
   			this.treeview.set_enable_search (false);
 			this.treeview.set_headers_visible (false);
-			this.treeview.set_rules_hint (true);
 			this.treeview.set_model (this.filter);
 
 			var cell = new Gtk.CellRendererText ();
@@ -104,22 +105,20 @@ namespace Xfmpc {
 
 			this.menu = new Gtk.Menu ();
 
-			var mi = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.REMOVE, null);
+			var mi = new Gtk.MenuItem.with_mnemonic (_("Remove"));
 			this.menu.append (mi);
 			mi.activate.connect (delete_selection);
-			this.mi_browse = new Gtk.ImageMenuItem.with_mnemonic (_("Browse"));
-			var image = new Gtk.Image.from_stock (Gtk.Stock.OPEN, Gtk.IconSize.MENU);
-			this.mi_browse.set_image (image);
+			this.mi_browse = new Gtk.MenuItem.with_mnemonic (_("Browse"));
 			this.menu.append (this.mi_browse);
 			this.mi_browse.activate.connect (cb_browse_selection);
-			this.mi_information = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.INFO, null);
+			this.mi_information = new Gtk.MenuItem.with_mnemonic (_("Info"));
 			this.menu.append (mi_information);
 			this.mi_information.activate.connect (cb_info_selection);
 
 			this.menu.show_all ();
 
 			this.filter_entry = new Entry ();
-			this.filter_entry.set_icon_from_stock (EntryIconPosition.PRIMARY, Gtk.Stock.FIND);
+			this.filter_entry.set_icon_from_icon_name (EntryIconPosition.PRIMARY, "edit-find");
 			this.filter_entry.set_icon_activatable (EntryIconPosition.PRIMARY, false);
 			this.filter_entry.set_icon_activatable (EntryIconPosition.SECONDARY, true);
 
@@ -316,7 +315,7 @@ namespace Xfmpc {
 		}
 
 		private void menu_popup () {
-			menu.popup (null, null, null, 0, get_current_event_time ());
+			menu.popup_at_pointer (null);
 		}
 
 		private void cb_filter_entry_activated () {
@@ -354,10 +353,10 @@ namespace Xfmpc {
 
 		private void cb_filter_entry_changed () {
 			if (filter_entry.get_text () != "") {
-				filter_entry.set_icon_from_stock (EntryIconPosition.SECONDARY, Gtk.Stock.CLEAR);
+				filter_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, "edit-clear");
 			}
 			else {
-				filter_entry.set_icon_from_stock (EntryIconPosition.SECONDARY, null);
+				filter_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, null);
 			}
   			this.filter.refilter ();
 		}
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index cca9633..36e10d4 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -102,7 +102,7 @@ namespace Xfmpc {
 				this.entry_passwd.set_text (this.preferences.mpd_password);
 			hbox.pack_start (this.entry_passwd, true, true, 0);
 
-			var button = new Gtk.Button.from_stock (Gtk.Stock.APPLY);
+			var button = new Gtk.Button.with_label (_("Apply"));
 			button.clicked.connect (cb_update_mpd);
 			vbox2.pack_start (button, true, true, 0);
 
@@ -172,52 +172,61 @@ namespace Xfmpc {
 			label = new Gtk.Label (_("Available parameters:"));
 			vbox2.pack_start (label, true, true, 0);
 
-			var table = new Gtk.Table (2, 6, true);
-			table.set_col_spacings (6);
-			table.set_row_spacings (6);
+			var grid = new Gtk.Grid();
+			grid.set_column_spacing (6);
+			grid.set_row_spacing (6);
+			grid.set_column_homogeneous(true);
 
 			var attrs = new Pango.AttrList ();
 			attrs.insert (Pango.attr_scale_new ((double) Pango.Scale.SMALL));
 
 			label = new Gtk.Label (_("%a: Artist"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 1, 2, 0, 1);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 1, 0, 1, 1);
 			label = new Gtk.Label (_("%A: Album"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 1, 2, 1, 2);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 1, 1, 1, 1);
 
 			label = new Gtk.Label (_("%t: Title"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 2, 3, 0, 1);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 2, 0, 1, 1);
 			label = new Gtk.Label (_("%D: Disc"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 2, 3, 1, 2);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 2, 1, 1, 1);
 
 			label = new Gtk.Label (_("%f: File"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 3, 4, 0, 1);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 3, 0, 1, 1);
 			label = new Gtk.Label (_("%g: Genre"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 3, 4, 1, 2);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 3, 1, 1, 1);
 
 			label = new Gtk.Label (_("%d: Date"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 4, 5, 0, 1);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 4, 0, 1, 1);
 			label = new Gtk.Label (_("%T: Track"));
 			label.set_attributes (attrs);
-			label.set_alignment (0, 0.5f);
-			table.attach_defaults (label, 4, 5, 1, 2);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
+			grid.attach (label, 4, 1, 1, 1);
 
-			vbox2.pack_start (table, true, true, 0);
+			vbox2.pack_start (grid, true, true, 0);
 
-			add_button (Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE);
+			add_button (_("Close"), Gtk.ResponseType.CLOSE);
 
 			show_all ();
 
diff --git a/src/shortcuts-dialog.vala b/src/shortcuts-dialog.vala
index db3374a..428f2fd 100644
--- a/src/shortcuts-dialog.vala
+++ b/src/shortcuts-dialog.vala
@@ -28,7 +28,7 @@ namespace Xfmpc {
 			this.title = _("Xfmpc Shortcuts");
 			this.subtitle = _("Control your MPD client with your keyboard");
 
-			add_button (Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE);
+			add_button (_("Close"), Gtk.ResponseType.CLOSE);
 			this.response.connect ((response) => {
 				switch (response) {
 					case Gtk.ResponseType.CLOSE:
@@ -46,27 +46,33 @@ namespace Xfmpc {
 
 			/* Shortcuts labels */
 			var label = new Gtk.Label (_("Quit: CTRL+q"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			label = new Gtk.Label (_("Previous: CTRL+b"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			label = new Gtk.Label (_("Play/Pause: CTRL+p"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			label = new Gtk.Label (_("Stop: CTRL+s"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			label = new Gtk.Label (_("Next: CTRL+f"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			label = new Gtk.Label (_("Volume: CTRL+v"));
-			label.set_alignment (0.0f, 0.5f);
+			label.xalign = 0.0f;
+			label.yalign = 0.5f;
 			vbox.add (label);
 
 			show_all ();
diff --git a/src/song-dialog.vala b/src/song-dialog.vala
index 54fc12f..844e522 100644
--- a/src/song-dialog.vala
+++ b/src/song-dialog.vala
@@ -99,7 +99,7 @@ namespace Xfmpc {
 
 			get_content_area ().pack_start (frame, true, true, 0);
 
-			add_button (Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE);
+			add_button (_("Close"), Gtk.ResponseType.CLOSE);
 
 			show_all ();
 
diff --git a/src/xfce-arrow-button.c b/src/xfce-arrow-button.c
index d63b508..cd05f93 100644
--- a/src/xfce-arrow-button.c
+++ b/src/xfce-arrow-button.c
@@ -52,28 +52,34 @@ enum
     PROP_ARROW_TYPE
 };
 
-static void   xfce_arrow_button_class_init    (XfceArrowButtonClass  *klass);
-static void   xfce_arrow_button_init          (XfceArrowButton       *button);
-static void   xfce_arrow_button_set_property  (GObject               *object,
-                                               guint                  prop_id,
-                                               const GValue          *value,
-                                               GParamSpec            *pspec);
-static void   xfce_arrow_button_get_property  (GObject               *object,
-                                               guint                  prop_id,
-                                               GValue                *value,
-                                               GParamSpec            *pspec);
-static gint   xfce_arrow_button_draw          (GtkWidget             *widget,
-                                               cairo_t               *cr,
-                                               gpointer               user_data);
-static void   xfce_arrow_button_add           (GtkContainer          *container,
-                                               GtkWidget             *child);
-static GType  xfce_arrow_button_child_type    (GtkContainer          *container);
-static void   xfce_arrow_button_get_preferred_width  (GtkWidget      *widget,
-                                                      gint           *minimal_width,
-                                                      gint           *natural_width);
-static void   xfce_arrow_button_get_preferred_height (GtkWidget      *widget,
-                                                      gint           *minimal_height,
-                                                      gint           *natural_height);
+typedef struct {
+    gint x;
+    gint y;
+} xfce_arrow_button_thickness;
+
+static void      xfce_arrow_button_class_init    (XfceArrowButtonClass  *klass);
+static void      xfce_arrow_button_init          (XfceArrowButton       *button);
+static void      xfce_arrow_button_set_property  (GObject               *object,
+                                                  guint                  prop_id,
+                                                  const GValue          *value,
+                                                  GParamSpec            *pspec);
+static void      xfce_arrow_button_get_property  (GObject               *object,
+                                                  guint                  prop_id,
+                                                  GValue                *value,
+                                                  GParamSpec            *pspec);
+static gboolean  xfce_arrow_button_draw          (GtkWidget             *widget,
+                                                  cairo_t               *cr);
+static void      xfce_arrow_button_add           (GtkContainer          *container,
+                                                  GtkWidget             *child);
+static void      xfce_arrow_button_get_thickness (GtkStyleContext *context,
+                                                  xfce_arrow_button_thickness *thickness);
+static GType     xfce_arrow_button_child_type    (GtkContainer          *container);
+static void      xfce_arrow_button_get_preferred_width  (GtkWidget      *widget,
+                                                         gint           *minimal_width,
+                                                         gint           *natural_width);
+static void      xfce_arrow_button_get_preferred_height (GtkWidget      *widget,
+                                                         gint           *minimal_height,
+                                                         gint           *natural_height);
 
 
 /* global vars */
@@ -221,25 +227,23 @@ xfce_arrow_button_get_property (GObject    *object,
 
 
 
-static gint
+static gboolean
 xfce_arrow_button_draw (GtkWidget      *widget,
-                        cairo_t        *cr,
-                        gpointer        user_data)
+                        cairo_t        *cr)
 {
     gint x, y, w;
-    GtkStyle *style;
     GtkStyleContext *context;
+    xfce_arrow_button_thickness thickness;
     GtkAllocation allocation;
 
     if (G_LIKELY (gtk_widget_is_drawable (widget)))
     {
-        style = gtk_widget_get_style (widget);
         context = gtk_widget_get_style_context (widget);
-
+        xfce_arrow_button_get_thickness (context, &thickness);
         gtk_widget_get_allocation (widget, &allocation);
 
-        w = MIN (allocation.height - 2 * style->ythickness,
-                 allocation.width  - 2 * style->xthickness);
+        w = MIN (allocation.height - 2 * thickness.y,
+                 allocation.width  - 2 * thickness.x);
         w = MIN (w, ARROW_WIDTH);
 
         x = (allocation.width - w) / 2;
@@ -265,13 +269,15 @@ xfce_arrow_button_get_preferred_width (GtkWidget *widget,
                                        gint      *minimal_width,
                                        gint      *natural_width)
 {
-    GtkStyle *style;
+    GtkStyleContext *context;
+    xfce_arrow_button_thickness thickness;
     gint size;
 
-    style = gtk_widget_get_style (widget);
+    context = gtk_widget_get_style_context (widget);
+    xfce_arrow_button_get_thickness (context, &thickness);
 
     size = ARROW_WIDTH + ARROW_PADDING +
-                2 * MAX (style->xthickness, style->ythickness);
+                2 * MAX (thickness.x, thickness.y);
 
     *minimal_width = *natural_width = size;
 }
@@ -283,13 +289,15 @@ xfce_arrow_button_get_preferred_height (GtkWidget *widget,
                                         gint      *minimal_height,
                                         gint      *natural_height)
 {
-    GtkStyle *style;
+    GtkStyleContext *context;
+    xfce_arrow_button_thickness thickness;
     gint size;
 
-    style = gtk_widget_get_style (widget);
+    context = gtk_widget_get_style_context (widget);
+    xfce_arrow_button_get_thickness (context, &thickness);
 
     size = ARROW_WIDTH + ARROW_PADDING +
-                2 * MAX (style->xthickness, style->ythickness);
+                2 * MAX (thickness.x, thickness.y);
 
     *minimal_height = *natural_height = size;
 }
@@ -297,6 +305,27 @@ xfce_arrow_button_get_preferred_height (GtkWidget *widget,
 
 
 static void
+xfce_arrow_button_get_thickness (GtkStyleContext *context, xfce_arrow_button_thickness *thickness)
+{
+    GtkBorder border;
+    GtkBorder margin;
+    GtkBorder padding;
+    gint xthickness;
+    gint ythickness;
+
+    gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
+    gtk_style_context_get_margin (context, GTK_STATE_FLAG_NORMAL, &margin);
+    gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
+
+    thickness->x = MAX (border.left + margin.left + padding.left,
+                        border.right + margin.right + padding.right);
+    thickness->y = MAX (border.top + margin.top + padding.top,
+                        border.bottom + margin.bottom + padding.bottom);
+}
+
+
+
+static void
 xfce_arrow_button_add (GtkContainer *container,
                        GtkWidget    *child)
 {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list