Skip to content

Commit

Permalink
Merge pull request #463 from Rafostar/ms-win
Browse files Browse the repository at this point in the history
Support MS Windows
  • Loading branch information
Rafostar committed Jun 21, 2024
2 parents 3f2e5d5 + 07f850d commit 9f54c10
Show file tree
Hide file tree
Showing 52 changed files with 697 additions and 20 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
name: "Windows"
jobs:
windows:
name: "Windows"
runs-on: windows-latest
strategy:
matrix:
arch: [x86_64]
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: |-
mingw-w64-${{ matrix.arch }}-meson
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-glib2
mingw-w64-${{ matrix.arch }}-gstreamer
mingw-w64-${{ matrix.arch }}-gst-plugins-base
mingw-w64-${{ matrix.arch }}-gst-plugins-good
mingw-w64-${{ matrix.arch }}-gst-plugins-bad
mingw-w64-${{ matrix.arch }}-gst-plugins-ugly
mingw-w64-${{ matrix.arch }}-gst-libav
mingw-w64-${{ matrix.arch }}-libsoup3
mingw-w64-${{ matrix.arch }}-libmicrodns
mingw-w64-${{ matrix.arch }}-gtk4
mingw-w64-${{ matrix.arch }}-libadwaita
- name: Prepare
run: |
BUILD_PREFIX="$GITHUB_WORKSPACE/clapper-win-${{ matrix.arch }}"
mkdir -p $BUILD_PREFIX/bin
cp /mingw64/bin/gdbus.exe $BUILD_PREFIX/bin/
cp /mingw64/bin/gst-inspect-1.0.exe $BUILD_PREFIX/bin/
mkdir -p $BUILD_PREFIX/lib
cp -r /mingw64/lib/gio $BUILD_PREFIX/lib/
cp -r /mingw64/lib/gstreamer-1.0 $BUILD_PREFIX/lib/
cp -r /mingw64/lib/gdk-pixbuf-2.0 $BUILD_PREFIX/lib/
mkdir -p $BUILD_PREFIX/share/glib-2.0/schemas
cp -r /mingw64/share/glib-2.0/schemas/*.xml $BUILD_PREFIX/share/glib-2.0/schemas/
cp -r /mingw64/share/icons $BUILD_PREFIX/share/
mkdir -p $BUILD_PREFIX/share/xml/iso-codes
cp /mingw64/share/xml/iso-codes/iso_639.xml $BUILD_PREFIX/share/xml/iso-codes/
cd "$BUILD_PREFIX/lib/gstreamer-1.0"
rm -f \
libgstadpcmenc.dll libgstamfcodec.dll libgstdvbsubenc.dll libgstencoding.dll \
libgstfrei0r.dll libgstinter.dll libgstlame.dll libgstldac.dll libgstmpeg2enc.dll \
libgstmpegpsmux.dll libgstmpegtsmux.dll libgstmplex.dll libgstrealmedia.dll \
libgstsubenc.dll libgstsvtav1.dll libgstsvthevcenc.dll libgsttwolame.dll \
libgstvoamrwbenc.dll libgstwavenc.dll libgstx264.dll libgstx265.dll \
libgstxingmux.dll libgsty4menc.dll libgstzbar.dll
- name: Build
run: |
meson setup builddir --prefix=$GITHUB_WORKSPACE/clapper-win-${{ matrix.arch }}
cd builddir
meson compile
meson install
- name: Package
run: |
BUILD_PREFIX="$GITHUB_WORKSPACE/clapper-win-${{ matrix.arch }}"
ldd $BUILD_PREFIX/bin/clapper.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp -n "{}" $BUILD_PREFIX/bin
find $BUILD_PREFIX/lib/clapper-0.0/ -name '*\.dll' -type f -exec ldd "{}" \; | grep '\/mingw.*\.dll' -o | xargs -I{} cp -n "{}" $BUILD_PREFIX/bin
find $BUILD_PREFIX/lib/gstreamer-1.0/ -name '*\.dll' -type f -exec ldd "{}" \; | grep '\/mingw.*\.dll' -o | xargs -I{} cp -n "{}" $BUILD_PREFIX/bin
find $BUILD_PREFIX/lib/gio/ -name '*\.dll' -type f -exec ldd "{}" \; | grep '\/mingw.*\.dll' -o | xargs -I{} cp -n "{}" $BUILD_PREFIX/bin
- name: Upload
uses: actions/upload-artifact@v4
with:
name: clapper-win-${{ matrix.arch }}
path: clapper-win-${{ matrix.arch }}
if-no-files-found: error
17 changes: 16 additions & 1 deletion src/bin/clapper-app/clapper-app-file-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ _dialog_add_mime_types (GtkFileDialog *dialog, const gchar *filter_name,
GtkFileFilter *filter = gtk_file_filter_new ();
guint i;

for (i = 0; mime_types[i]; ++i)
/* XXX: Windows does not support mime-types file
* filters, so use file extensions instead */
for (i = 0; mime_types[i]; ++i) {
#ifndef G_OS_WIN32
gtk_file_filter_add_mime_type (filter, mime_types[i]);
#else
gtk_file_filter_add_suffix (filter, mime_types[i]);
#endif
}

gtk_file_filter_set_name (filter, filter_name);
g_list_store_append (filters, filter);
Expand All @@ -99,7 +106,11 @@ clapper_app_file_dialog_open_files (GtkApplication *gtk_app)
GtkFileDialog *dialog = gtk_file_dialog_new ();

_dialog_add_mime_types (dialog, "Media Files",
#ifndef G_OS_WIN32
clapper_app_utils_get_mime_types ());
#else
clapper_app_utils_get_extensions ());
#endif

gtk_file_dialog_set_modal (dialog, TRUE);
gtk_file_dialog_set_title (dialog, "Add Files");
Expand All @@ -118,7 +129,11 @@ clapper_app_file_dialog_open_subtitles (GtkApplication *gtk_app, ClapperMediaIte
GtkFileDialog *dialog = gtk_file_dialog_new ();

_dialog_add_mime_types (dialog, "Subtitles",
#ifndef G_OS_WIN32
clapper_app_utils_get_subtitles_mime_types ());
#else
clapper_app_utils_get_subtitles_extensions ());
#endif

gtk_file_dialog_set_modal (dialog, TRUE);
gtk_file_dialog_set_title (dialog, "Open Subtitles");
Expand Down
42 changes: 42 additions & 0 deletions src/bin/clapper-app/clapper-app-types.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Clapper Application
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "clapper-app-types.h"

#include "clapper-app-headerbar.h"
#include "clapper-app-media-item-box.h"
#include "clapper-app-property-row.h"
#include "clapper-app-queue-list.h"
#include "clapper-app-queue-progression-model.h"
#include "clapper-app-window-state-buttons.h"

/*
* clapper_app_types_init:
*
* Ensure private types that appear in UI files in order for
* GtkBuilder to be able to find them when building templates.
*/
inline void
clapper_app_types_init (void)
{
g_type_ensure (CLAPPER_APP_TYPE_HEADERBAR);
g_type_ensure (CLAPPER_APP_TYPE_MEDIA_ITEM_BOX);
g_type_ensure (CLAPPER_APP_TYPE_PROPERTY_ROW);
g_type_ensure (CLAPPER_APP_TYPE_QUEUE_LIST);
g_type_ensure (CLAPPER_APP_TYPE_QUEUE_PROGRESSION_MODEL);
g_type_ensure (CLAPPER_APP_TYPE_WINDOW_STATE_BUTTONS);
}
27 changes: 27 additions & 0 deletions src/bin/clapper-app/clapper-app-types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Clapper Application
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <glib.h>

G_BEGIN_DECLS

G_GNUC_INTERNAL
void clapper_app_types_init (void);

G_END_DECLS
24 changes: 24 additions & 0 deletions src/bin/clapper-app/clapper-app-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@
#include "clapper-app-utils.h"
#include "clapper-app-media-item-box.h"

/* Useful only on Windows */
#ifdef G_OS_WIN32
const gchar *const *
clapper_app_utils_get_extensions (void)
{
static const gchar *const all_extensions[] = {
"avi", "claps", "m2ts", "mkv", "mov",
"mp4", "webm", "wmv", NULL
};

return all_extensions;
}

const gchar *const *
clapper_app_utils_get_subtitles_extensions (void)
{
static const gchar *const subs_extensions[] = {
"srt", "vtt", NULL
};

return subs_extensions;
}
#endif

const gchar *const *
clapper_app_utils_get_mime_types (void)
{
Expand Down
8 changes: 8 additions & 0 deletions src/bin/clapper-app/clapper-app-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ G_BEGIN_DECLS

typedef void (* ClapperAppUtilsIterRanks) (const gchar *feature_name, GstRank rank, gboolean from_env, gpointer user_data);

#ifdef G_OS_WIN32
G_GNUC_INTERNAL
const gchar *const * clapper_app_utils_get_extensions (void);

G_GNUC_INTERNAL
const gchar *const * clapper_app_utils_get_subtitles_extensions (void);
#endif

G_GNUC_INTERNAL
const gchar *const * clapper_app_utils_get_mime_types (void);

Expand Down
2 changes: 2 additions & 0 deletions src/bin/clapper-app/clapper-app-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ typedef struct
gint64 last_tick;
} ClapperAppWindowResizeData;

#if CLAPPER_HAVE_MPRIS
static guint16 instance_count = 0;
#endif

static inline GQuark
clapper_app_window_extra_options_get_quark (void)
Expand Down
31 changes: 18 additions & 13 deletions src/bin/clapper-app/data/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if not ['linux'].contains(host_machine.system())
subdir_done()
endif

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file',
Expand Down Expand Up @@ -29,22 +25,31 @@ endif
install_subdir('icons',
install_dir: join_paths(prefix, datadir)
)
install_subdir('mime',
install_dir: join_paths(prefix, datadir)
)
install_subdir('applications',
install_dir: join_paths(prefix, datadir)
)
install_subdir('metainfo',
install_dir: join_paths(prefix, datadir)
)

is_linux = ['linux'].contains(host_machine.system())
is_windows = ['windows'].contains(host_machine.system())

if is_linux
install_subdir('applications',
install_dir: join_paths(prefix, datadir)
)
subdir('dbus-1')
endif

if not is_windows
install_subdir('mime',
install_dir: join_paths(prefix, datadir)
)
endif

subdir('glib-2.0/schemas')
subdir('dbus-1')

gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
update_desktop_database: true,
update_mime_database: true,
update_desktop_database: is_linux,
update_mime_database: not is_windows,
)
3 changes: 3 additions & 0 deletions src/bin/clapper-app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <clapper/clapper.h>

#include "clapper-app-application.h"
#include "clapper-app-types.h"

gint
main (gint argc, gchar **argv)
Expand All @@ -46,6 +47,8 @@ main (gint argc, gchar **argv)
gtk_init ();
adw_init ();

clapper_app_types_init ();

g_set_application_name ("Clapper");

application = clapper_app_application_new ();
Expand Down
14 changes: 14 additions & 0 deletions src/bin/clapper-app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ clapperapp_sources = [
'clapper-app-queue-progression-item.c',
'clapper-app-queue-progression-model.c',
'clapper-app-queue-selection.c',
'clapper-app-types.c',
'clapper-app-uri-dialog.c',
'clapper-app-utils.c',
'clapper-app-window.c',
Expand All @@ -87,5 +88,18 @@ executable(
c_args: clapperapp_c_args,
install: true,
install_dir: bindir,
win_subsystem: 'windows',
)
if ['windows'].contains(host_machine.system())
executable(
meson.project_name() + '-console',
clapperapp_sources,
dependencies: clapperapp_deps,
include_directories: clapperapp_conf_inc,
c_args: clapperapp_c_args,
install: true,
install_dir: bindir,
win_subsystem: 'console',
)
endif
build_clapperapp = true
8 changes: 8 additions & 0 deletions src/lib/clapper-gtk/clapper-gtk-billboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,33 @@
#include <glib-object.h>
#include <gtk/gtk.h>

#include <clapper-gtk/clapper-gtk-visibility.h>
#include <clapper-gtk/clapper-gtk-container.h>

G_BEGIN_DECLS

#define CLAPPER_GTK_TYPE_BILLBOARD (clapper_gtk_billboard_get_type())
#define CLAPPER_GTK_BILLBOARD_CAST(obj) ((ClapperGtkBillboard *)(obj))

CLAPPER_GTK_API
G_DECLARE_FINAL_TYPE (ClapperGtkBillboard, clapper_gtk_billboard, CLAPPER_GTK, BILLBOARD, ClapperGtkContainer)

CLAPPER_GTK_API
GtkWidget * clapper_gtk_billboard_new (void);

CLAPPER_GTK_API
void clapper_gtk_billboard_post_message (ClapperGtkBillboard *billboard, const gchar *icon_name, const gchar *message);

CLAPPER_GTK_API
void clapper_gtk_billboard_pin_message (ClapperGtkBillboard *billboard, const gchar *icon_name, const gchar *message);

CLAPPER_GTK_API
void clapper_gtk_billboard_unpin_pinned_message (ClapperGtkBillboard *billboard);

CLAPPER_GTK_API
void clapper_gtk_billboard_announce_volume (ClapperGtkBillboard *billboard);

CLAPPER_GTK_API
void clapper_gtk_billboard_announce_speed (ClapperGtkBillboard *billboard);

G_END_DECLS
Loading

0 comments on commit 9f54c10

Please sign in to comment.