diff --git a/src/bin/clapper-app/clapper-app-queue-list.c b/src/bin/clapper-app/clapper-app-queue-list.c
index eb7982c0..2c22f1f1 100644
--- a/src/bin/clapper-app/clapper-app-queue-list.c
+++ b/src/bin/clapper-app/clapper-app-queue-list.c
@@ -89,7 +89,7 @@ drag_item_prepare_cb (GtkDragSource *drag_source, gdouble x, gdouble y, ClapperA
paintable = gtk_widget_paintable_new (list_widget);
- drag_data = g_new0 (ClapperAppQueueListDragData, 1);
+ drag_data = g_new (ClapperAppQueueListDragData, 1);
drag_data->item = gst_object_ref (item);
drag_data->widget = g_object_ref_sink (pickup);
drag_data->paintable = gdk_paintable_get_current_image (paintable);
@@ -150,8 +150,12 @@ queue_drop_value_notify_cb (GtkDropTarget *drop_target,
{
const GValue *value = gtk_drop_target_get_value (drop_target);
- if (value && !clapper_app_utils_value_for_item_is_valid (value))
- gtk_drop_target_reject (drop_target);
+ if (value) {
+ if (!clapper_app_utils_value_for_item_is_valid (value))
+ gtk_drop_target_reject (drop_target);
+ } else {
+ self->list_target = NULL; // Reset when value is lost
+ }
}
static GdkDragAction
@@ -223,6 +227,7 @@ queue_drop_leave_cb (GtkDropTarget *drop_target, ClapperAppQueueList *self)
if (self->list_target) {
gtk_widget_set_margin_top (self->list_target, 0);
gtk_widget_set_margin_bottom (self->list_target, 0);
+ self->list_target = NULL;
}
}
@@ -230,55 +235,75 @@ static gboolean
queue_drop_cb (GtkDropTarget *drop_target, const GValue *value,
gdouble x, gdouble y, ClapperAppQueueList *self)
{
- ClapperQueue *queue;
- ClapperMediaItem *item;
- GtkWidget *pickup;
+ ClapperPlayer *player = clapper_gtk_get_player_from_ancestor (GTK_WIDGET (self));
+ ClapperQueue *queue = clapper_player_get_queue (player);
+ ClapperMediaItem *item = NULL;
guint drop_index = 0;
gboolean success = FALSE;
- if (G_UNLIKELY (self->list_target == NULL))
- return FALSE;
+ if (self->list_target) {
+ GtkWidget *pickup = gtk_widget_get_first_child (self->list_target);
- pickup = gtk_widget_get_first_child (self->list_target);
+ /* Reset margins on drop */
+ gtk_widget_set_margin_top (self->list_target, 0);
+ gtk_widget_set_margin_bottom (self->list_target, 0);
+ self->list_target = NULL;
- /* Reset margins on drop */
- gtk_widget_set_margin_top (self->list_target, 0);
- gtk_widget_set_margin_bottom (self->list_target, 0);
- self->list_target = NULL;
+ if (G_UNLIKELY (pickup == NULL) || !CLAPPER_APP_IS_MEDIA_ITEM_BOX (pickup))
+ return FALSE;
- if (G_UNLIKELY (pickup == NULL) || !CLAPPER_APP_IS_MEDIA_ITEM_BOX (pickup))
- return FALSE;
+ item = clapper_app_media_item_box_get_media_item (CLAPPER_APP_MEDIA_ITEM_BOX_CAST (pickup));
- item = clapper_app_media_item_box_get_media_item (CLAPPER_APP_MEDIA_ITEM_BOX_CAST (pickup));
- queue = CLAPPER_QUEUE (gst_object_get_parent (GST_OBJECT (item)));
+ if (!clapper_queue_find_item (queue, item, &drop_index))
+ return FALSE;
- if (G_UNLIKELY (queue == NULL))
- return FALSE;
-
- if (!clapper_queue_find_item (queue, item, &drop_index)) {
- gst_object_unref (queue);
- return FALSE;
+ if (self->drop_after)
+ drop_index++;
+ } else {
+ drop_index = clapper_queue_get_n_items (queue); // Append
}
- if (self->drop_after)
- drop_index++;
-
/* Moving item with widget */
if (G_VALUE_HOLDS (value, GTK_TYPE_WIDGET)) {
ClapperAppQueueListDragData *drag_data;
drag_data = (ClapperAppQueueListDragData *) g_object_get_data (G_OBJECT (self), "drag-data");
- /* Insert at different place */
- if (item != drag_data->item) {
- guint index = 0;
+ /* When user drops a widget and drag data is present, it means
+ * that it is an item drop within the same window */
+ if (drag_data) {
+ /* Insert at different place */
+ if (item != drag_data->item) {
+ guint index = 0;
- if (clapper_queue_find_item (queue, drag_data->item, &index)) {
- if (drop_index > index)
- drop_index--;
+ if (clapper_queue_find_item (queue, drag_data->item, &index)) {
+ if (drop_index > index)
+ drop_index--;
- clapper_queue_reposition_item (queue, drag_data->item, drop_index);
- success = TRUE;
+ clapper_queue_reposition_item (queue, drag_data->item, drop_index);
+ success = TRUE;
+ }
+ }
+ } else { // Drop from another window
+ GtkWidget *drop_widget = GTK_WIDGET (g_value_get_object (value));
+
+ if (G_LIKELY (CLAPPER_APP_IS_MEDIA_ITEM_BOX (drop_widget))) {
+ ClapperMediaItem *drop_item;
+ ClapperQueue *src_queue;
+
+ drop_item = clapper_app_media_item_box_get_media_item (
+ CLAPPER_APP_MEDIA_ITEM_BOX_CAST (drop_widget));
+
+ if ((src_queue = CLAPPER_QUEUE (gst_object_get_parent (GST_OBJECT (drop_item))))) {
+ gst_object_ref (drop_item); // Ref so it survives queue removal
+
+ clapper_queue_remove_item (src_queue, drop_item);
+ clapper_queue_insert_item (queue, drop_item, drop_index);
+ success = TRUE;
+
+ gst_object_unref (drop_item); // Unref after placed in new queue
+ gst_object_unref (src_queue);
+ }
}
}
} else {
@@ -300,8 +325,6 @@ queue_drop_cb (GtkDropTarget *drop_target, const GValue *value,
}
}
- gst_object_unref (queue);
-
return success;
}
diff --git a/src/bin/clapper-app/clapper-app-window.c b/src/bin/clapper-app/clapper-app-window.c
index 19a4c5ea..ed5c5be8 100644
--- a/src/bin/clapper-app/clapper-app-window.c
+++ b/src/bin/clapper-app/clapper-app-window.c
@@ -335,37 +335,36 @@ _resize_tick (GtkWidget *widget, GdkFrameClock *frame_clock,
return G_SOURCE_CONTINUE;
}
+static gint
+_get_gcd (gint width, gint height)
+{
+ return (height > 0)
+ ? _get_gcd (height, width % height)
+ : width;
+}
+
static void
_calculate_win_resize (gint win_w, gint win_h,
gint vid_w, gint vid_h, gint *dest_w, gint *dest_h)
{
- gdouble win_aspect = (gdouble) win_w / win_h;
- gdouble vid_aspect = (gdouble) vid_w / vid_h;
+ /* Get the smallest integer ratio (e.g. 1920x1080 becomes 16x9) */
+ gint gcd = _get_gcd (vid_w, vid_h);
+ gint min_w = vid_w / gcd;
+ gint min_h = vid_h / gcd;
- if (win_aspect < vid_aspect) {
- while (!G_APPROX_VALUE (fmod (win_w, vid_aspect), 0, FLT_EPSILON))
- win_w++;
+ /* Find the scale multiplier that best fits video */
+ gint scale_fit = MIN (win_w / min_w, win_h / min_h);
- win_h = round ((gdouble) win_w / vid_aspect);
+ /* Calculate minimal allowed scale for video (-1 for ceil) */
+ gint scale_min = MAX (
+ (MIN_WINDOW_WIDTH + min_w - 1) / min_w,
+ (MIN_WINDOW_HEIGHT + min_h - 1) / min_h);
- if (win_h < MIN_WINDOW_HEIGHT) {
- _calculate_win_resize (G_MAXINT, MIN_WINDOW_HEIGHT, vid_w, vid_h, dest_w, dest_h);
- return;
- }
- } else {
- while (!G_APPROX_VALUE (fmod (win_h * vid_aspect, 1.0), 0, FLT_EPSILON))
- win_h++;
+ /* Select best allowed scale multiplier */
+ gint scale = MAX (scale_fit, scale_min);
- win_w = round ((gdouble) win_h * vid_aspect);
-
- if (win_w < MIN_WINDOW_WIDTH) {
- _calculate_win_resize (MIN_WINDOW_WIDTH, G_MAXINT, vid_w, vid_h, dest_w, dest_h);
- return;
- }
- }
-
- *dest_w = win_w;
- *dest_h = win_h;
+ *dest_w = min_w * scale;
+ *dest_h = min_h * scale;
}
static void
@@ -1283,6 +1282,7 @@ clapper_app_window_constructed (GObject *object)
if ((proxy = clapper_enhancer_proxy_list_get_proxy_by_module (proxies, "clapper-mpris"))) {
clapper_enhancer_proxy_set_locally (proxy,
+ "app-id", CLAPPER_APP_ID,
"own-name", mpris_name,
"identity", CLAPPER_APP_NAME,
"desktop-entry", CLAPPER_APP_ID,
diff --git a/src/bin/clapper-app/meson.build b/src/bin/clapper-app/meson.build
index b9b1f38b..8c5f0d8b 100644
--- a/src/bin/clapper-app/meson.build
+++ b/src/bin/clapper-app/meson.build
@@ -91,6 +91,7 @@ clapperapp_sources = [
clapperapp_c_args = [
'-DG_LOG_DOMAIN="ClapperApp"',
'-DCLAPPER_APP_INTERNAL_COMPILATION',
+ '-DCLAPPER_DISABLE_DEPRECATION_WARNINGS',
'-DGST_USE_UNSTABLE_API',
]
diff --git a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui
index a36ddc53..965d116e 100644
--- a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui
+++ b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui
@@ -6,7 +6,7 @@
cancel
add
false
- 420
+ 460