*What kind of thing.
Being unable to edit titles on Reddit is annoying.
I'm looking to create a GUI app for my Linux machine. It's not going to go into production, I just want to be able to create something. Looking all over the place, there are a hundred different things I can do, and almost all of the tutorials require me to learn another language or something.
Now, I'm sure this may be necessary, but if there's one thing I've learnt over my years of studying computing, if you ask "what is the best x for y?" you'll get as many different responses as there are responders. Learning a new language always leaves me as a perpetual beginner, and I'd rather build on what I already know, than start again.
Currently, I am very familiar with Bash, PHP, MySQL, and to a certain extent C++. I also know HTML and CSS.
What I'd like to do is build a GUI for a media player. I've already created a rudimentary CLI for one, and it works, though it's far from pretty. I've tried to create a web based one, and I got fairly far into it, using PHP on the backend, and MySQL for the database, but the limits of HTML mean I cannot harness the power of my preferred Matroska format for videos (something I've been able to do in my terminal based app).
I write almost exclusively in plain text files, and don't use an IDE. Foolish? Probably. But I find it far more portable and easier to understand.
The idea I have, is for me to have a GUI to display the contents of the database, and to organise it in a pretty way to be user friendly, and then when you click on something to play it, it launches MPV player with all the relevant commands I give it. I'm not sure I want to build something with the player built in, as that would probably be far too much work for what I want. And besides, my current CLI app does exactly this, so it would, again, be building on my current knowledge.
What I would like, is for something that would allow me to programme the GUI in an XML like structure, similar to HTML, and style with CSS, use PHP as a backend script to connect to MySQL, and be able to execute terminal based commands so I can launch MPV. Pretty much a website kind of thing that can launch other apps. I have no idea if this is possible, but it would work with what I already know. If it's not possible, is there any kind of thing that would work without requiring me to go right back to the beginning too much?
Edit:
After some tinkering, I think the best thing for me to do is to use C++ with GTK. I have built a minimal working example that prints out the tables of a database, or plays a video. I'm going to build on this, but with the following example I can see how I can achieve what I want.
```
include <gtk/gtk.h>
include <stdio.h>
include <stdlib.h>
include <string.h>
include <mysql/mysql.h>
static void
print_hello (GtkWidget widget,
gpointer data)
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
const char server = "localhost";
const char* user = "root";
const char* password = "password"; /* set me first /
const char database = "testdb";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
g_print ("Hello World\n");
}
static void
print_hello2 (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World! You clicked button 2!\n");
system("mpv /path/to/video.mkv");
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *button;
/* create a new window, and set its title */
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
/* Here we construct the container that is going pack our buttons */
grid = gtk_grid_new ();
/* Pack the container in the window */
gtk_window_set_child (GTK_WINDOW (window), grid);
button = gtk_button_new_with_label ("Button 1");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
/* Place the first button in the grid cell (0, 0), and make it fill
* just 1 cell horizontally and vertically (ie no spanning)
*/
gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
button = gtk_button_new_with_label ("Button 2");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello2), NULL);
/* Place the second button in the grid cell (1, 0), and make it fill
* just 1 cell horizontally and vertically (ie no spanning)
*/
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
button = gtk_button_new_with_label ("Quit");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
/* Place the Quit button in the grid cell (0, 1), and make it
* span 2 columns.
*/
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);
gtk_window_present (GTK_WINDOW (window));
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```