Skip to content

Commit

Permalink
Merge pull request #13 from soyersoyer/appfix
Browse files Browse the repository at this point in the history
Add icon, desktop file, metainfo for easier packaging; use GtkApplication for better DE integration
  • Loading branch information
tsmetana authored Jan 24, 2024
2 parents 4f2f371 + f51ebb4 commit 82ef686
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 16 deletions.
9 changes: 9 additions & 0 deletions pkg/com.github.tsmetana.mpk3-settings.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=MPK3 Settings
Comment=AKAI MPK Mini MK3 settings
Exec=mpk3-settings
Icon=com.github.tsmetana.mpk3-settings
Terminal=false
Categories=Settings;
32 changes: 32 additions & 0 deletions pkg/com.github.tsmetana.mpk3-settings.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>com.github.tsmetana.mpk3-settings</id>
<launchable type="desktop-id">com.github.tsmetana.mpk3-settings</launchable>
<name>MPK3 Settings</name>
<summary>AKAI MPK Mini MK3 settings</summary>
<description>
<p>
This is a GTK UI that allows to configure the Akai MPK mini III MIDI keyboard.
It currently allows for reading the programs settings, changing them and writing back
to the device and reading and writing the settings to a file.
It's in a very early stage of development and has not been thoroughly tested.
</p>
</description>
<metadata_license>FSFAP</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<supports>
<control>pointing</control>
<control>keyboard</control>
<display_length compare="ge">large</display_length>
</supports>
<content_rating type="oars-1.0"/>
<url type="homepage">https://github.com/tsmetana/mpk3-settings</url>
<url type="bugtracker">https://github.com/tsmetana/mpk3-settings/issues</url>
<screenshots>
<screenshot type="default">
<image>https://github.com/tsmetana/mpk3-settings/raw/main/pkg/gui_screen_1.png</image>
</screenshot>
</screenshots>
<releases>
</releases>
</component>
124 changes: 124 additions & 0 deletions pkg/com.github.tsmetana.mpk3-settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkg/gui_screen_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions src/app_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ enum _file_dialog_e {
typedef enum _file_dialog_e file_dialog_t;


static void on_app_win_delete(GtkWidget *app_win, gpointer user_data)
{
gtk_main_quit();
}

static gchar *file_choose_dialog(GtkWidget *app_win, file_dialog_t dlg_type)
{
GtkWidget *dialog;
Expand Down Expand Up @@ -671,16 +666,15 @@ static void on_app_win_realize(GtkWidget *win, gpointer user_data)
}


GtkWidget *app_win_create(void)
GtkWidget *app_win_create(GtkApplication *app)
{
GtkWidget *main_window;
GtkWidget *main_vbox;
GtkWidget *main_menu;
GtkWidget *main_hbox;

main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
main_window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(main_window), "MPKmini MK3 Settings");
g_signal_connect(main_window, "delete-event", G_CALLBACK(on_app_win_delete), NULL);

main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_spacing(GTK_BOX(main_vbox), 5);
Expand Down
2 changes: 1 addition & 1 deletion src/app_win.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef APP_WIN_H
#define APP_WIN_H

GtkWidget *app_win_create(void);
GtkWidget *app_win_create(GtkApplication *app);

#endif
27 changes: 20 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@ void show_error(void)
GTK_BUTTONS_CLOSE,
"Error: No suitable device found.");
gtk_window_set_title(GTK_WINDOW(dialog), "MPKmini MK3 Settings");
gtk_dialog_run(GTK_DIALOG (dialog));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}

static void
activate(GtkApplication *app, gpointer user_data)
{
GtkWidget *window;

window = app_win_create(app);
gtk_widget_show_all(window);
gtk_window_present(GTK_WINDOW(window));
}


int main(int argc, char ** argv)
{
GtkWidget *app_win;

GtkApplication *app;
int status;

gtk_init(&argc, &argv);
if (device_init() < 0) {
show_error();
Expand All @@ -34,10 +46,11 @@ int main(int argc, char ** argv)
show_error();
return -1;
}
app_win = app_win_create();
gtk_widget_show_all(app_win);
gtk_main();
app = gtk_application_new("com.github.tsmetana.mpk3-settings", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
device_close();

return 0;
return status;
}

0 comments on commit 82ef686

Please sign in to comment.