Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xfmpc gtk3 port
diff --git a/configure.in.in b/configure.in.in
index eb69a65..c4c0347 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -57,10 +57,10 @@ dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_LIBX11_REQUIRE()
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.22.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.18.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.8.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.8.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
XDT_CHECK_PACKAGE([LIBMPD], [libmpd], [0.15.0])
dnl ***********************
diff --git a/src/Makefile.am b/src/Makefile.am
index 33f306d..d8f83bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,7 @@ xfmpc_VALAFLAGS = \
--header=xfmpc.h \
--vapidir=. \
--vapidir=$(top_srcdir)/third-party \
- --pkg=libxfce4ui-1 \
+ --pkg=libxfce4ui-2 \
--pkg=config \
--pkg=mpdclient \
--pkg=xfce-arrow-button
diff --git a/src/extended-interface.vala b/src/extended-interface.vala
index 3787b93..d82c2f2 100644
--- a/src/extended-interface.vala
+++ b/src/extended-interface.vala
@@ -52,7 +52,7 @@ namespace Xfmpc {
this.mpdclient = Xfmpc.Mpdclient.get_default ();
this.preferences = Xfmpc.Preferences.get_default ();
- var hbox = new Gtk.HBox (false, 2);
+ var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
pack_start (hbox, false, false, 2);
var button = new Gtk.Button ();
@@ -121,7 +121,8 @@ namespace Xfmpc {
this.combobox.set_active (0);
this.notebook.append_page (child, null);
- this.notebook.set_tab_label_packing (child, true, true, Gtk.PackType.START);
+ this.notebook.child_set_property (child, "tab-expand", true);
+ this.notebook.child_set_property (child, "tab-fill", true);
}
private void popup_context_menu () {
@@ -139,18 +140,22 @@ namespace Xfmpc {
}
private static void position_context_menu (Gtk.Menu menu, int x, int y, bool push_in) {
- Gtk.Requisition menu_req;
+ Gtk.Allocation allocation;
int root_x;
int root_y;
+ int pref_height;
- menu.size_request (out menu_req);
- (((Gtk.Widget) context_button).window).get_origin (out root_x, out root_y);
+ 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 + (((Gtk.Widget) context_button).allocation).x;
- y = root_y + (((Gtk.Widget) context_button).allocation).y;
+ x = root_x + allocation.x;
+ y = root_y + allocation.y;
+ x = 0;
+ y = 0;
- if (y > Gdk.Screen.height () - menu_req.height)
- y = Gdk.Screen.height () - menu_req.height;
+ if (y > Gdk.Screen.height () - pref_height)
+ y = Gdk.Screen.height () - pref_height;
else if (y < 0)
y = 0;
diff --git a/src/interface.vala b/src/interface.vala
index 266bfba..a942e58 100644
--- a/src/interface.vala
+++ b/src/interface.vala
@@ -102,7 +102,7 @@ namespace Xfmpc {
this.subtitle.set_alignment (0, (float) 0.5);
/* === Containers === */
- var box = new Gtk.HBox (false, 0);
+ var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
pack_start (box, false, false, 0);
box.pack_start (this.button_prev, false, false, 0);
box.pack_start (this.button_pp, false, false, 0);
@@ -110,7 +110,7 @@ namespace Xfmpc {
box.pack_start (progress_box, true, true, 4);
box.pack_start (this.button_volume, false, false, 0);
- var vbox = new Gtk.VBox (false, 0);
+ var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
pack_start (vbox, false, true, 0);
vbox.add (this.title);
vbox.add (this.subtitle);
@@ -164,7 +164,9 @@ namespace Xfmpc {
if (time_total < 0)
return false;
- double song_time = event.x / this.progress_bar.allocation.width;
+ Gtk.Allocation allocation;
+ this.progress_bar.get_allocation (out allocation);
+ double song_time = event.x / allocation.width;
song_time *= time_total;
if (song_time < 0)
@@ -193,7 +195,9 @@ namespace Xfmpc {
if (time_total < 0)
return false;
- double song_time = event.x / this.progress_bar.allocation.width;
+ Gtk.Allocation allocation;
+ this.progress_bar.get_allocation (out allocation);
+ double song_time = event.x / allocation.width;
song_time *= time_total;
this.mpdclient.set_song_time ((int) song_time);
diff --git a/src/main-window.vala b/src/main-window.vala
index a9ee290..a54ecfa 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -32,7 +32,7 @@ namespace Xfmpc {
private Xfmpc.Interface @interface;
private Xfmpc.ExtendedInterface extended_interface;
- private Gtk.VBox vbox;
+ private Gtk.Box vbox;
private Gtk.ActionGroup action_group;
private Gtk.UIManager ui_manager;
private Xfmpc.Statusbar statusbar;
@@ -81,7 +81,7 @@ namespace Xfmpc {
this.delete_event.connect (cb_window_closed);
this.window_state_event.connect (cb_window_state_event);
- this.vbox = new Gtk.VBox (false, 0);
+ this.vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
add (vbox);
if (this.preferences.last_window_posx != -1 && this.preferences.last_window_posy != -1)
@@ -132,7 +132,7 @@ namespace Xfmpc {
this.preferences.notify["show-statusbar"].connect (cb_show_statusbar_changed);
/* === Timeout === */
- Gtk.Timeout.add (1000, refresh);
+ Gdk.threads_add_timeout (1000, refresh);
}
private void show_hide_status_icon () {
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 1d65210..cca9633 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -31,15 +31,14 @@ namespace Xfmpc {
private Gtk.SpinButton entry_port;
private Gtk.CheckButton show_status_icon;
private Gtk.CheckButton show_statusbar;
- private Gtk.ComboBox combo_format;
+ private Gtk.ComboBoxText combo_format;
private Gtk.Entry entry_custom;
private uint format_timeout;
- private Gtk.VBox mpd_vbox;
+ private Gtk.Box mpd_vbox;
construct {
- this.has_separator = true;
this.skip_taskbar_hint = true;
this.icon_name = "stock_volume";
this.resizable = false;
@@ -50,16 +49,17 @@ namespace Xfmpc {
var notebook = new Gtk.Notebook ();
notebook.set_border_width (6);
- this.vbox.pack_start (notebook, true, true, 0);
+ this.get_content_area ().pack_start (notebook, true, true, 0);
/* Mpd Settings */
- var vbox = new Gtk.VBox (false, 6);
+ var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
vbox.set_border_width (6);
var label = new Gtk.Label (_("MPD"));
notebook.append_page (vbox, label);
- var vbox2 = new Gtk.VBox (false, 6);
+ var vbox2 = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
var frame = Xfce.gtk_frame_box_new_with_content (_("Connection"), vbox2);
+ frame.ref_sink ();
vbox.pack_start (frame, false, false, 0);
this.entry_use_defaults = new Gtk.CheckButton.with_mnemonic (_("Use _default system settings"));
@@ -68,13 +68,13 @@ namespace Xfmpc {
vbox2.pack_start (this.entry_use_defaults, false, false, 0);
- this.mpd_vbox = new Gtk.VBox (false, 6);
+ this.mpd_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
vbox2.pack_start (this.mpd_vbox, false, false, 0);
this.entry_use_defaults.toggled.connect (cb_use_defaults_toggled);
this.mpd_vbox.set_sensitive (!this.entry_use_defaults.get_active ());
- var hbox = new Gtk.HBox (false, 2);
+ var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
this.mpd_vbox.pack_start (hbox, false, false, 0);
label = new Gtk.Label (_("Hostname:"));
@@ -91,7 +91,7 @@ namespace Xfmpc {
this.entry_port.set_value (this.preferences.mpd_port);
hbox.pack_start (this.entry_port, true, true, 0);
- hbox = new Gtk.HBox (false, 2);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
this.mpd_vbox.pack_start (hbox, false, false, 0);
label = new Gtk.Label (_("Password:"));
@@ -107,13 +107,14 @@ namespace Xfmpc {
vbox2.pack_start (button, true, true, 0);
/* Display */
- vbox = new Gtk.VBox (false, 6);
+ vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
vbox.set_border_width (6);
label = new Gtk.Label (_("Appearance"));
notebook.append_page (vbox, label);
- vbox2 = new Gtk.VBox (false, 6);
+ vbox2 = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
frame = Xfce.gtk_frame_box_new_with_content (_("General"), vbox2);
+ frame.ref_sink ();
vbox.pack_start (frame, false, false, 0);
this.show_status_icon = new Gtk.CheckButton.with_mnemonic (_("Close window into notification area"));
@@ -126,31 +127,32 @@ namespace Xfmpc {
this.show_statusbar.toggled.connect (cb_show_statusbar_toggled);
vbox2.pack_start (this.show_statusbar, false, false, 0);
- vbox2 = new Gtk.VBox (false, 6);
+ vbox2 = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
frame = Xfce.gtk_frame_box_new_with_content (_("Song Format"), vbox2);
+ frame.ref_sink ();
vbox.pack_start (frame, false, false, 0);
- hbox = new Gtk.HBox (false, 2);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
label = new Gtk.Label (_("Song Format:"));
hbox.pack_start (label, false, false, 0);
- this.combo_format = new Gtk.ComboBox.text ();
+ this.combo_format = new Gtk.ComboBoxText ();
hbox.pack_start (this.combo_format, true, true, 0);
- this.combo_format.append_text (_("Title"));
- this.combo_format.append_text (_("Album - Title"));
- this.combo_format.append_text (_("Artist - Title"));
- this.combo_format.append_text (_("Artist - Title (Date)"));
- this.combo_format.append_text (_("Artist - Album - Title"));
- this.combo_format.append_text (_("Artist - Album - Track. Title"));
- this.combo_format.append_text (_("Custom..."));
+ this.combo_format.append (null, _("Title"));
+ this.combo_format.append (null, _("Album - Title"));
+ this.combo_format.append (null, _("Artist - Title"));
+ this.combo_format.append (null, _("Artist - Title (Date)"));
+ this.combo_format.append (null, _("Artist - Album - Title"));
+ this.combo_format.append (null, _("Artist - Album - Track. Title"));
+ this.combo_format.append (null, _("Custom..."));
this.combo_format.set_active (this.preferences.song_format);
vbox2.pack_start (hbox, true, true, 0);
- hbox = new Gtk.HBox (false, 2);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
label = new Gtk.Label (_("Custom format:"));
hbox.pack_start (label, false, false, 0);
diff --git a/src/shortcuts-dialog.vala b/src/shortcuts-dialog.vala
index be32d3a..db3374a 100644
--- a/src/shortcuts-dialog.vala
+++ b/src/shortcuts-dialog.vala
@@ -22,7 +22,6 @@ namespace Xfmpc {
public class ShortcutsDialog : Xfce.TitledDialog {
construct {
- this.has_separator = true;
this.skip_taskbar_hint = true;
this.icon_name = "stock_volume";
this.resizable = false;
@@ -38,9 +37,10 @@ namespace Xfmpc {
}
});
- var content_area = (Gtk.VBox)get_content_area ();
+ var content_area = (Gtk.Box)get_content_area ();
- var vbox = new Gtk.VBox (true, 6);
+ var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
+ vbox.set_homogeneous (true);
vbox.set_border_width (6);
content_area.add (vbox);
diff --git a/src/song-dialog.vala b/src/song-dialog.vala
index 9b99295..54fc12f 100644
--- a/src/song-dialog.vala
+++ b/src/song-dialog.vala
@@ -27,7 +27,6 @@ namespace Xfmpc {
private unowned Xfmpc.SongInfo song;
public SongDialog (int song_id) {
- this.has_separator = true;
this.skip_taskbar_hint = true;
this.icon_name = "stock_volume";
this.resizable = false;
@@ -37,15 +36,15 @@ namespace Xfmpc {
this.title = this.song.title;
- this.vbox.set_spacing (0);
+ this.get_content_area ().set_spacing (0);
- var vbox2 = new Gtk.VBox (false, 0);
+ var vbox2 = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
var frame = Xfce.gtk_frame_box_new_with_content ("", vbox2);
var attrs = new Pango.AttrList ();
attrs.insert (Pango.attr_weight_new (Pango.Weight.BOLD));
- var hbox = new Gtk.HBox (false, 0);
+ var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
var label = new Gtk.Label (_("File"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -53,7 +52,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- hbox = new Gtk.HBox (false, 0);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
label = new Gtk.Label (_("Artist"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -61,7 +60,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- hbox = new Gtk.HBox (false, 0);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
label = new Gtk.Label (_("Title"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -69,7 +68,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- hbox = new Gtk.HBox (false, 0);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
label = new Gtk.Label (_("Album"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -77,7 +76,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- hbox = new Gtk.HBox (false, 0);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
label = new Gtk.Label (_("Date"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -90,7 +89,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- hbox = new Gtk.HBox (false, 0);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
label = new Gtk.Label (_("Genre"));
label.set_attributes (attrs);
hbox.pack_start (label, false, false, 5);
@@ -98,7 +97,7 @@ namespace Xfmpc {
hbox.pack_start (label, false, false, 5);
vbox2.pack_start (hbox, false, false, 6);
- vbox.pack_start (frame, true, true, 0);
+ get_content_area ().pack_start (frame, true, true, 0);
add_button (Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE);
diff --git a/src/statusbar.vala b/src/statusbar.vala
index eebebaf..7371d01 100644
--- a/src/statusbar.vala
+++ b/src/statusbar.vala
@@ -35,7 +35,6 @@ namespace Xfmpc {
}
construct {
- set_has_resize_grip (false);
this.context_id = get_context_id ("Main text");
}
}
diff --git a/src/xfce-arrow-button.c b/src/xfce-arrow-button.c
index 9c4770f..d63b508 100644
--- a/src/xfce-arrow-button.c
+++ b/src/xfce-arrow-button.c
@@ -62,14 +62,18 @@ static void xfce_arrow_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static gint xfce_arrow_button_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void xfce_arrow_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+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);
/* global vars */
@@ -81,7 +85,7 @@ static guint arrow_button_signals[LAST_SIGNAL] = { 0 };
GType
xfce_arrow_button_get_type (void)
{
- static GtkType type = G_TYPE_INVALID;
+ static GType type = G_TYPE_INVALID;
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
@@ -120,8 +124,9 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass)
gobject_class->set_property = xfce_arrow_button_set_property;
widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->expose_event = xfce_arrow_button_expose;
- widget_class->size_request = xfce_arrow_button_size_request;
+ widget_class->draw = xfce_arrow_button_draw;
+ widget_class->get_preferred_width = xfce_arrow_button_get_preferred_width;
+ widget_class->get_preferred_height = xfce_arrow_button_get_preferred_height;
container_class = GTK_CONTAINER_CLASS (klass);
container_class->add = xfce_arrow_button_add;
@@ -169,9 +174,7 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass)
static void
xfce_arrow_button_init (XfceArrowButton * arrow_button)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (arrow_button), GTK_NO_WINDOW);
- arrow_button->arrow_type = DEFAULT_ARROW_TYPE;
}
@@ -219,27 +222,37 @@ xfce_arrow_button_get_property (GObject *object,
static gint
-xfce_arrow_button_expose (GtkWidget *widget,
- GdkEventExpose *event)
+xfce_arrow_button_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer user_data)
{
gint x, y, w;
+ GtkStyle *style;
+ GtkStyleContext *context;
+ GtkAllocation allocation;
- if (G_LIKELY (GTK_WIDGET_DRAWABLE (widget)))
+ if (G_LIKELY (gtk_widget_is_drawable (widget)))
{
- w = MIN (widget->allocation.height - 2 * widget->style->ythickness,
- widget->allocation.width - 2 * widget->style->xthickness);
+ style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ w = MIN (allocation.height - 2 * style->ythickness,
+ allocation.width - 2 * style->xthickness);
w = MIN (w, ARROW_WIDTH);
- x = widget->allocation.x + (widget->allocation.width - w) / 2;
- y = widget->allocation.y + (widget->allocation.height - w) / 2;
+ x = (allocation.width - w) / 2;
+ y = (allocation.height - w) / 2;
+
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
- gtk_paint_arrow (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE,
- &(event->area), widget, "xfce_arrow_button",
- XFCE_ARROW_BUTTON (widget)->arrow_type, FALSE,
- x, y, w, w);
+ gtk_render_arrow (context, cr, G_PI, x, y, w);
+
+ gtk_style_context_restore (context);
}
return TRUE;
@@ -248,13 +261,37 @@ xfce_arrow_button_expose (GtkWidget *widget,
static void
-xfce_arrow_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+xfce_arrow_button_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkStyle *style;
+ gint size;
+
+ style = gtk_widget_get_style (widget);
+
+ size = ARROW_WIDTH + ARROW_PADDING +
+ 2 * MAX (style->xthickness, style->ythickness);
+
+ *minimal_width = *natural_width = size;
+}
+
+
+
+static void
+xfce_arrow_button_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
{
- gint size = ARROW_WIDTH + ARROW_PADDING +
- 2 * MAX (widget->style->xthickness, widget->style->ythickness);
+ GtkStyle *style;
+ gint size;
+
+ style = gtk_widget_get_style (widget);
+
+ size = ARROW_WIDTH + ARROW_PADDING +
+ 2 * MAX (style->xthickness, style->ythickness);
- requisition->width = requisition->height = size;
+ *minimal_height = *natural_height = size;
}
@@ -271,7 +308,7 @@ xfce_arrow_button_add (GtkContainer *container,
static GType
xfce_arrow_button_child_type (GtkContainer *container)
{
- return GTK_TYPE_NONE;
+ return G_TYPE_NONE;
}
diff --git a/third-party/libxfce4ui-1.deps b/third-party/libxfce4ui-2.deps
similarity index 65%
rename from third-party/libxfce4ui-1.deps
rename to third-party/libxfce4ui-2.deps
index b47d055..a3e4885 100644
--- a/third-party/libxfce4ui-1.deps
+++ b/third-party/libxfce4ui-2.deps
@@ -1,8 +1,8 @@
atk
-gio-2.0
+gio-3.0
cairo
pango
gdk-pixbuf-2.0
-gdk-2.0
-gtk+-2.0
+gdk-3.0
+gtk+-3.0
libxfce4util-1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.