mirror of https://github.com/daleclack/My_GtkUi
Add Media Player
This commit is contained in:
parent
85d3c550d5
commit
51aa8be783
|
@ -1 +1 @@
|
||||||
Subproject commit b5a7fe5719ed0df8998b2ba961e09d967a385ec6
|
Subproject commit 6ea69eca6817aead20a2cb87cdd08ab8e9a173cd
|
|
@ -21,12 +21,10 @@
|
||||||
"/usr/include/uuid/**",
|
"/usr/include/uuid/**",
|
||||||
*/
|
*/
|
||||||
//For manjaro(Arch linux)
|
//For manjaro(Arch linux)
|
||||||
|
|
||||||
"/usr/lib/dbus-1.0/include/**",
|
"/usr/lib/dbus-1.0/include/**",
|
||||||
"/usr/lib/glib-2.0/include/**",
|
"/usr/lib/glib-2.0/include/**",
|
||||||
"/usr/include/lzo/**",
|
"/usr/include/lzo/**",
|
||||||
"/usr/include/cloudproviders/**",
|
"/usr/include/cloudproviders/**",
|
||||||
|
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
"/usr/include/gtk-3.0/**",
|
"/usr/include/gtk-3.0/**",
|
||||||
"/usr/include/at-spi2-atk/2.0/**",
|
"/usr/include/at-spi2-atk/2.0/**",
|
||||||
|
|
|
@ -35,6 +35,7 @@ set(RESOURCE_LIST
|
||||||
icons/16x16/actions/window-minimize.png
|
icons/16x16/actions/window-minimize.png
|
||||||
icons/16x16/actions/drawing_app.png
|
icons/16x16/actions/drawing_app.png
|
||||||
icons/16x16/actions/file-app.png
|
icons/16x16/actions/file-app.png
|
||||||
|
icons/16x16/actions/multimedia-player1.png
|
||||||
icons/24x24/actions/view-grid-symbolic.png
|
icons/24x24/actions/view-grid-symbolic.png
|
||||||
icons/24x24/actions/view-list-symbolic.png
|
icons/24x24/actions/view-list-symbolic.png
|
||||||
icons/48x48/actions/game.png
|
icons/48x48/actions/game.png
|
||||||
|
@ -48,6 +49,8 @@ set(RESOURCE_LIST
|
||||||
icons/48x48/actions/drawing_app_running.png
|
icons/48x48/actions/drawing_app_running.png
|
||||||
icons/48x48/actions/file-app.png
|
icons/48x48/actions/file-app.png
|
||||||
icons/48x48/actions/file-app-running.png
|
icons/48x48/actions/file-app-running.png
|
||||||
|
icons/48x48/actions/multimedia-player1.png
|
||||||
|
icons/48x48/actions/multimedia-player1_running.png
|
||||||
icons/scalable/status/graphics.svg
|
icons/scalable/status/graphics.svg
|
||||||
icons/scalable/status/log_out.svg
|
icons/scalable/status/log_out.svg
|
||||||
icons/scalable/status/system.svg
|
icons/scalable/status/system.svg
|
||||||
|
@ -55,6 +58,7 @@ set(RESOURCE_LIST
|
||||||
gnome-fs-directory.png
|
gnome-fs-directory.png
|
||||||
gnome-fs-regular.png
|
gnome-fs-regular.png
|
||||||
STRIPBLANKS appmenu.xml
|
STRIPBLANKS appmenu.xml
|
||||||
|
STRIPBLANKS media_menu.xml
|
||||||
STRIPBLANKS stack.ui
|
STRIPBLANKS stack.ui
|
||||||
STRIPBLANKS leftpanel.ui
|
STRIPBLANKS leftpanel.ui
|
||||||
STRIPBLANKS game1.ui)
|
STRIPBLANKS game1.ui)
|
||||||
|
@ -71,7 +75,7 @@ compile_gresources(RESOURCE_FILE
|
||||||
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
||||||
|
|
||||||
set(SOURCES src/main.cpp src/MainWin.cpp src/MainStack.cpp src/LeftPanel.cpp src/GameWin.cpp
|
set(SOURCES src/main.cpp src/MainWin.cpp src/MainStack.cpp src/LeftPanel.cpp src/GameWin.cpp
|
||||||
src/drawing.cpp src/TextEditor.cpp src/FileWindow.cpp src/winconf.cpp)
|
src/drawing.cpp src/TextEditor.cpp src/FileWindow.cpp src/winconf.cpp src/MediaPlayer.cpp)
|
||||||
|
|
||||||
# Step 4:Add the resource to compile list and compile
|
# Step 4:Add the resource to compile list and compile
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 586 B |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -292,6 +292,30 @@
|
||||||
<property name="label">Run</property>
|
<property name="label">Run</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnmedia">
|
||||||
|
<property name="visible">1</property>
|
||||||
|
<property name="focusable">1</property>
|
||||||
|
<property name="receives-default">1</property>
|
||||||
|
<property name="has-frame">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="pixel-size">16</property>
|
||||||
|
<property name="icon-name">multimedia-player</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Media Player</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="btneditor">
|
<object class="GtkButton" id="btneditor">
|
||||||
<property name="visible">1</property>
|
<property name="visible">1</property>
|
||||||
|
@ -399,5 +423,19 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="panel_media">
|
||||||
|
<property name="visible">1</property>
|
||||||
|
<property name="focusable">1</property>
|
||||||
|
<property name="receives-default">1</property>
|
||||||
|
<property name="has-frame">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="media_image">
|
||||||
|
<property name="pixel-size">48</property>
|
||||||
|
<property name="icon-name">multimedia-player1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</template>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<menu id='media-menu'>
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>Open Media File</attribute>
|
||||||
|
<attribute name='action'>win.open</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>Pause Media</attribute>
|
||||||
|
<attribute name='action'>win.pause</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>Play Media</attribute>
|
||||||
|
<attribute name='action'>win.play</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>Clear Media</attribute>
|
||||||
|
<attribute name='action'>win.clear</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>About</attribute>
|
||||||
|
<attribute name='action'>win.about</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name='label'>Exit</attribute>
|
||||||
|
<attribute name='action'>win.quit</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
|
</interface>
|
|
@ -6,6 +6,7 @@
|
||||||
#include "TextEditor.h"
|
#include "TextEditor.h"
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
#include "FileWindow.h"
|
#include "FileWindow.h"
|
||||||
|
#include "MediaPlayer.h"
|
||||||
|
|
||||||
struct _LeftPanel{
|
struct _LeftPanel{
|
||||||
GtkBox parent;
|
GtkBox parent;
|
||||||
|
@ -17,18 +18,19 @@ struct _LeftPanel{
|
||||||
//Button for win32 applications
|
//Button for win32 applications
|
||||||
GtkWidget * btn_vlc, * btn_note;
|
GtkWidget * btn_vlc, * btn_note;
|
||||||
//Integrated applications
|
//Integrated applications
|
||||||
GtkWidget * btnabout, * btnfiles, * btndraw, * btngame, * btnrun, * btneditor;
|
GtkWidget * btnabout, * btnfiles, * btndraw, * btngame, * btnrun, * btneditor, * btnmedia;
|
||||||
//Panel Buttons
|
//Panel Buttons
|
||||||
GtkWidget * panel_file, * panel_game, * panel_editor, * panel_drawing;
|
GtkWidget * panel_file, * panel_game, * panel_editor, * panel_drawing, * panel_media;
|
||||||
//Panel Images
|
//Panel Images
|
||||||
GtkWidget * file_image, * game_image, * editor_image, * drawing_image;
|
GtkWidget * file_image, * game_image, * editor_image, * drawing_image, * media_image;
|
||||||
//Application Windows
|
//Application Windows
|
||||||
GameWin * game1;
|
GameWin * game1;
|
||||||
FileWindow * file_win;
|
FileWindow * file_win;
|
||||||
DrawingApp * draw_win;
|
DrawingApp * draw_win;
|
||||||
TextEditor * editor_win;
|
TextEditor * editor_win;
|
||||||
|
MediaPlayer * media_player;
|
||||||
//Status
|
//Status
|
||||||
gboolean game_running, file_running, editor_running, drawapp_running;
|
gboolean game_running, file_running, editor_running, drawapp_running, media_running;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(LeftPanel,left_panel,GTK_TYPE_BOX)
|
G_DEFINE_TYPE(LeftPanel,left_panel,GTK_TYPE_BOX)
|
||||||
|
@ -193,6 +195,33 @@ static void btneditor_clicked(GtkWidget * widget,LeftPanel * parent_panel){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Functions for media player window
|
||||||
|
static gboolean media_player_closed(GtkWindow * window,LeftPanel * parent_panel){
|
||||||
|
parent_panel->media_running = FALSE;
|
||||||
|
gtk_image_set_from_icon_name(GTK_IMAGE(parent_panel->media_image),"multimedia-player1");
|
||||||
|
gtk_window_destroy(window);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void btnmedia_clicked(GtkWidget * widget,LeftPanel * parent_panel){
|
||||||
|
if(!parent_panel->media_running){
|
||||||
|
//Create a window
|
||||||
|
parent_panel->media_player = media_player_new(parent_panel->parent_win);
|
||||||
|
//Connect to the close signal for window
|
||||||
|
g_signal_connect(parent_panel->media_player,"close-request",G_CALLBACK(media_player_closed),parent_panel);
|
||||||
|
|
||||||
|
//Change Panel Status
|
||||||
|
gtk_image_set_from_icon_name(GTK_IMAGE(parent_panel->media_image),"multimedia-player1_running");
|
||||||
|
parent_panel->media_running = TRUE;
|
||||||
|
|
||||||
|
//Show Window
|
||||||
|
gtk_window_present(GTK_WINDOW(parent_panel->media_player));
|
||||||
|
}else{
|
||||||
|
//The Files Window is running, control the window
|
||||||
|
window_ctrl(parent_panel,GTK_WINDOW(parent_panel->media_player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void left_panel_init(LeftPanel * panel){
|
static void left_panel_init(LeftPanel * panel){
|
||||||
gtk_widget_init_template(GTK_WIDGET(panel));
|
gtk_widget_init_template(GTK_WIDGET(panel));
|
||||||
|
|
||||||
|
@ -205,6 +234,7 @@ static void left_panel_init(LeftPanel * panel){
|
||||||
panel->drawapp_running = FALSE;
|
panel->drawapp_running = FALSE;
|
||||||
panel->editor_running = FALSE;
|
panel->editor_running = FALSE;
|
||||||
panel->game_running = FALSE;
|
panel->game_running = FALSE;
|
||||||
|
panel->media_running = FALSE;
|
||||||
|
|
||||||
//Connect Signals
|
//Connect Signals
|
||||||
//Audacious media player
|
//Audacious media player
|
||||||
|
@ -237,11 +267,15 @@ static void left_panel_init(LeftPanel * panel){
|
||||||
//Drawing App
|
//Drawing App
|
||||||
g_signal_connect(panel->btndraw,"clicked",G_CALLBACK(btndraw_clicked),panel);
|
g_signal_connect(panel->btndraw,"clicked",G_CALLBACK(btndraw_clicked),panel);
|
||||||
g_signal_connect_swapped(panel->btndraw,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
|
g_signal_connect_swapped(panel->btndraw,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
|
||||||
|
//Media Player
|
||||||
|
g_signal_connect(panel->btnmedia,"clicked",G_CALLBACK(btnmedia_clicked),panel);
|
||||||
|
g_signal_connect_swapped(panel->btnmedia,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
|
||||||
//Panel Buttons
|
//Panel Buttons
|
||||||
g_signal_connect(panel->panel_game,"clicked",G_CALLBACK(btngame_clicked),panel);
|
g_signal_connect(panel->panel_game,"clicked",G_CALLBACK(btngame_clicked),panel);
|
||||||
g_signal_connect(panel->panel_file,"clicked",G_CALLBACK(btnfile_clicked),panel);
|
g_signal_connect(panel->panel_file,"clicked",G_CALLBACK(btnfile_clicked),panel);
|
||||||
g_signal_connect(panel->panel_editor,"clicked",G_CALLBACK(btneditor_clicked),panel);
|
g_signal_connect(panel->panel_editor,"clicked",G_CALLBACK(btneditor_clicked),panel);
|
||||||
g_signal_connect(panel->panel_drawing,"clicked",G_CALLBACK(btndraw_clicked),panel);
|
g_signal_connect(panel->panel_drawing,"clicked",G_CALLBACK(btndraw_clicked),panel);
|
||||||
|
g_signal_connect(panel->panel_media,"clicked",G_CALLBACK(btnmedia_clicked),panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void left_panel_class_init(LeftPanelClass * klass){
|
static void left_panel_class_init(LeftPanelClass * klass){
|
||||||
|
@ -262,6 +296,7 @@ static void left_panel_class_init(LeftPanelClass * klass){
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btngame);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btngame);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnrun);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnrun);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btneditor);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btneditor);
|
||||||
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnmedia);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_file);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_file);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,file_image);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,file_image);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_game);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_game);
|
||||||
|
@ -270,6 +305,8 @@ static void left_panel_class_init(LeftPanelClass * klass){
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,editor_image);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,editor_image);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_drawing);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_drawing);
|
||||||
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,drawing_image);
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,drawing_image);
|
||||||
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,panel_media);
|
||||||
|
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,media_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftPanel * left_panel_new(){
|
LeftPanel * left_panel_new(){
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
#include "MediaPlayer.h"
|
||||||
|
|
||||||
|
struct _MediaPlayer{
|
||||||
|
GtkApplicationWindow parent;
|
||||||
|
GtkWidget * video;
|
||||||
|
GtkWidget * menubtn;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE(MediaPlayer,media_player,GTK_TYPE_APPLICATION_WINDOW)
|
||||||
|
|
||||||
|
static void clear_activated(GSimpleAction *action,
|
||||||
|
GVariant *parmeter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
MediaPlayer * player = MEDIA_PLAYER(data);
|
||||||
|
|
||||||
|
GtkMediaStream * stream = gtk_video_get_media_stream(GTK_VIDEO(player->video));
|
||||||
|
gtk_media_file_clear(GTK_MEDIA_FILE(stream));
|
||||||
|
gtk_video_set_file(GTK_VIDEO(player->video),NULL);
|
||||||
|
//Set window title
|
||||||
|
gtk_window_set_title(GTK_WINDOW(data),"Gtk4 Media");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pause_activated(GSimpleAction *action,
|
||||||
|
GVariant *parmeter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
MediaPlayer * player = MEDIA_PLAYER(data);
|
||||||
|
GtkMediaStream *media=gtk_video_get_media_stream(GTK_VIDEO(player->video));
|
||||||
|
|
||||||
|
if(media!=NULL){
|
||||||
|
gtk_media_stream_pause(media);
|
||||||
|
g_object_unref(media);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void play_activated(GSimpleAction *action,
|
||||||
|
GVariant *parmeter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
MediaPlayer * player = MEDIA_PLAYER(data);
|
||||||
|
GtkMediaStream *media=gtk_video_get_media_stream(GTK_VIDEO(player->video));
|
||||||
|
|
||||||
|
if(media!=NULL){
|
||||||
|
gtk_media_stream_play(media);
|
||||||
|
g_object_unref(media);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void about_activated(GSimpleAction *action,
|
||||||
|
GVariant *parmeter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkWindow *win = GTK_WINDOW(data);
|
||||||
|
const char *authors[]={
|
||||||
|
"Dale Clack",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
//Program version
|
||||||
|
char *version;
|
||||||
|
version=g_strdup_printf("2.0\nRunning Against GTK %d.%d.%d",
|
||||||
|
gtk_get_major_version(),
|
||||||
|
gtk_get_minor_version(),
|
||||||
|
gtk_get_micro_version());
|
||||||
|
GtkWidget *dialog;
|
||||||
|
dialog=gtk_dialog_new();
|
||||||
|
gtk_show_about_dialog(win,
|
||||||
|
"program-name","Gtk4 Media",
|
||||||
|
"version",version,
|
||||||
|
"copyright", "© 2019—2021 The Xe Project",
|
||||||
|
"comments","A Simple Media Player",
|
||||||
|
"authors",authors,
|
||||||
|
"logo-icon-name","media-player1",
|
||||||
|
"title","About Gtk4 Media",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dialog_response(GtkWidget *widget,int response,MediaPlayer * player){
|
||||||
|
//Get File and set the file to the mediacontrols
|
||||||
|
if(response==GTK_RESPONSE_OK){
|
||||||
|
//Get media File and filename
|
||||||
|
char *filename=NULL;
|
||||||
|
GFile *file=gtk_file_chooser_get_file(GTK_FILE_CHOOSER(widget));
|
||||||
|
gtk_video_set_file(GTK_VIDEO(player->video),file);
|
||||||
|
filename=g_file_get_basename(file);
|
||||||
|
gtk_window_set_title(GTK_WINDOW(player),filename);
|
||||||
|
//Free the memory
|
||||||
|
g_object_unref(file);
|
||||||
|
free(filename);
|
||||||
|
}
|
||||||
|
gtk_window_destroy(GTK_WINDOW(widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void open_activated(GSimpleAction *action,
|
||||||
|
GVariant *parmeter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
//Set a dialog and choose the file
|
||||||
|
GtkWindow *parent = GTK_WINDOW(data);
|
||||||
|
GtkWidget *dialog;
|
||||||
|
GtkFileChooserAction action1=GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||||
|
dialog = gtk_file_chooser_dialog_new("Open Media File",parent,action1,
|
||||||
|
"OK",GTK_RESPONSE_OK,"Cancel",GTK_RESPONSE_CANCEL,NULL);
|
||||||
|
//Set filter
|
||||||
|
GtkFileFilter *filter;
|
||||||
|
filter=gtk_file_filter_new();
|
||||||
|
gtk_file_filter_add_pattern(filter,"*.mp3");
|
||||||
|
gtk_file_filter_add_pattern(filter,"*.wav");
|
||||||
|
gtk_file_filter_add_pattern(filter,"*.flac");
|
||||||
|
gtk_file_filter_add_pattern(filter,"*.aac");
|
||||||
|
gtk_file_filter_add_pattern(filter,"*.m4a");
|
||||||
|
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog),filter);
|
||||||
|
g_signal_connect(dialog,"response",G_CALLBACK(dialog_response),parent);
|
||||||
|
gtk_widget_show(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void quit_activated(GSimpleAction * action,GVariant * parmeter, gpointer data)
|
||||||
|
{
|
||||||
|
gtk_window_close(GTK_WINDOW(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void media_player_init(MediaPlayer * self){
|
||||||
|
//Initalize Window
|
||||||
|
GtkWidget * header = gtk_header_bar_new();
|
||||||
|
gtk_window_set_title(GTK_WINDOW(self),"Video Player");
|
||||||
|
gtk_window_set_titlebar(GTK_WINDOW(self),header);
|
||||||
|
|
||||||
|
//Ininalize Action
|
||||||
|
GActionEntry entries[] = {
|
||||||
|
{"quit",quit_activated,NULL,NULL,NULL},
|
||||||
|
{"open",open_activated,NULL,NULL,NULL},
|
||||||
|
{"play",play_activated,NULL,NULL,NULL},
|
||||||
|
{"pause",pause_activated,NULL,NULL,NULL},
|
||||||
|
{"clear",clear_activated,NULL,NULL,NULL},
|
||||||
|
{"about",about_activated,NULL,NULL,NULL}
|
||||||
|
};
|
||||||
|
g_action_map_add_action_entries(G_ACTION_MAP(self),entries,G_N_ELEMENTS(entries),self);
|
||||||
|
|
||||||
|
//Add Menu
|
||||||
|
self->menubtn = gtk_menu_button_new();
|
||||||
|
GtkBuilder * menu_builder = gtk_builder_new_from_resource("/org/gtk/daleclack/media_menu.xml");
|
||||||
|
GMenuModel * model = G_MENU_MODEL(gtk_builder_get_object(menu_builder,"media-menu"));
|
||||||
|
GtkWidget * popover = gtk_popover_menu_new_from_model(model);
|
||||||
|
gtk_widget_set_halign(popover,GTK_ALIGN_END);
|
||||||
|
gtk_menu_button_set_popover(GTK_MENU_BUTTON(self->menubtn),popover);
|
||||||
|
gtk_header_bar_pack_end(GTK_HEADER_BAR(header),self->menubtn);
|
||||||
|
|
||||||
|
//Create video
|
||||||
|
self->video = gtk_video_new();
|
||||||
|
gtk_widget_set_size_request(self->video,400,200);
|
||||||
|
gtk_window_set_child(GTK_WINDOW(self),self->video);
|
||||||
|
|
||||||
|
g_object_unref(menu_builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void media_player_class_init(MediaPlayerClass * klass){}
|
||||||
|
|
||||||
|
MediaPlayer * media_player_new(GtkWindow * parent_win){
|
||||||
|
return (MediaPlayer*)g_object_new(media_player_get_type(),"transient-for",parent_win,NULL);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE(MediaPlayer,media_player,MEDIA,PLAYER,GtkApplicationWindow)
|
||||||
|
|
||||||
|
MediaPlayer * media_player_new(GtkWindow * parent_win);
|
Loading…
Reference in New Issue