aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-05-04 21:29:20 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-05-04 21:29:20 +0200
commit1574afef9e64bd598fc386d754ef8d46795cdbb0 (patch)
treef21cac84157eddacb9b59088f2d08b00d9b2e03b
parent1b0605ae2ef81e0b936cf18b4dad2d39e835f75d (diff)
downloadexperiment-player-1574afef9e64bd598fc386d754ef8d46795cdbb0.tar.gz
use GtkBuilder for UI, more sophisticated UI
default UI file is installed (/usr/share/experiment-player/default.ui) but the actually used file may be changed via --with-default-ui=... (useful for windows where it should read --with-default-ui=default.ui)
-rw-r--r--configure.ac12
-rw-r--r--lib/gtk-vlc-player/Makefile.am2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/default.ui159
-rw-r--r--src/main.c33
5 files changed, 200 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index bf881a0..4d74789 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,9 +92,21 @@ AC_TYPE_SIZE_T
AC_FUNC_MALLOC
AC_FUNC_REALLOC
+# Experiment player data directory
+player_datadir=$datarootdir/$PACKAGE_TARNAME
+AC_SUBST(player_datadir)
+
#
# Config options
#
+AC_ARG_WITH(default-ui,
+ AS_HELP_STRING([--with-default-ui=PATH],
+ [Specify default UI definition to use [default=DATAROOTDIR/experiment-player/default.ui]]),
+ [DEFAULT_UI=$withval], [DEFAULT_UI=$player_datadir/default.ui])
+# NOTE: cannot use AC_DEFINE_UNQUOTED since installation directories
+# must be expanded by the Makefiles
+AC_SUBST(DEFAULT_UI)
+
AC_ARG_ENABLE(doxygen-doc,
AS_HELP_STRING([--enable-doxygen-doc],
[Generate Doxygen documentation [default=no]]),
diff --git a/lib/gtk-vlc-player/Makefile.am b/lib/gtk-vlc-player/Makefile.am
index f71cf6a..c5241ef 100644
--- a/lib/gtk-vlc-player/Makefile.am
+++ b/lib/gtk-vlc-player/Makefile.am
@@ -1,6 +1,6 @@
AM_CFLAGS = -Wall
-vlcplayer_datadir = $(datarootdir)/gtk-vlc-player
+vlcplayer_datadir = @datarootdir@/gtk-vlc-player
lib_LTLIBRARIES = libgtk-vlc-player.la
libgtk_vlc_player_la_SOURCES = gtk-vlc-player.c gtk-vlc-player.h
diff --git a/src/Makefile.am b/src/Makefile.am
index f5c53cc..6fa4307 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,7 @@ bin_PROGRAMS = experiment-player
experiment_player_SOURCES = main.c
experiment_player_CFLAGS =
-experiment_player_CPPFLAGS =
+experiment_player_CPPFLAGS = -DDEFAULT_UI='"@DEFAULT_UI@"'
experiment_player_LDFLAGS =
experiment_player_LDADD =
@@ -16,3 +16,5 @@ experiment_player_LDADD += @LIBGTK_LIBS@
experiment_player_CFLAGS += @GTKAPP_CFLAGS@
experiment_player_LDFLAGS += @GTKAPP_LDFLAGS@
+
+dist_player_data_DATA = default.ui
diff --git a/src/default.ui b/src/default.ui
new file mode 100644
index 0000000..6854bcd
--- /dev/null
+++ b/src/default.ui
@@ -0,0 +1,159 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-requires gtk-vlc-player 0.0 -->
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="player_window">
+ <property name="title" translatable="yes">Experiment Player</property>
+ <property name="default_width">400</property>
+ <property name="default_height">300</property>
+ <child>
+ <object class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuBar" id="menubar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuItem" id="file_item">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_File</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="file_menu">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="file_menu_openmovie_item">
+ <property name="label" translatable="yes">Open _Movie...</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="image">image1</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="file_menu_opentranscript_item">
+ <property name="label" translatable="yes">Open _Transcript...</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="image">image2</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="file_menu_separator_item">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="file_menu_quit_item">
+ <property name="label">gtk-quit</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="help_item">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="help_menu">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="help_menu_about_item">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVlcPlayer" id="player_widget">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHScale" id="scale_widget">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="draw_value">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="playpause_button">
+ <property name="label">gtk-media-play</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="playpause_button_clicked_cb" object="player_widget"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="stop_button">
+ <property name="label">gtk-media-stop</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="stop_button_clicked_cb" object="player_widget"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-open</property>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-open</property>
+ </object>
+</interface>
diff --git a/src/main.c b/src/main.c
index df2f9ef..e57d175 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,9 +9,29 @@
#include <gtk/gtk.h>
#include <gtk-vlc-player.h>
+/*
+ * GtkBuilder signal callbacks
+ */
+
+void
+playpause_button_clicked_cb(GtkWidget *widget,
+ gpointer data __attribute__((unused)))
+{
+ gtk_vlc_player_toggle(GTK_VLC_PLAYER(widget));
+}
+
+void
+stop_button_clicked_cb(GtkWidget *widget,
+ gpointer data __attribute__((unused)))
+{
+ gtk_vlc_player_stop(GTK_VLC_PLAYER(widget));
+}
+
+
int
main(int argc, char *argv[])
{
+ GtkBuilder *builder;
GtkWidget *window, *player;
/* init threads */
@@ -23,20 +43,17 @@ main(int argc, char *argv[])
gtk_init(&argc, &argv);
-#if 0
- GtkBuilder *builder = gtk_builder_new();
+ builder = gtk_builder_new();
- gtk_builder_add_from_file(builder, file, NULL);
+ gtk_builder_add_from_file(builder, DEFAULT_UI, NULL);
gtk_builder_connect_signals(builder, NULL);
-#endif
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ window = GTK_WIDGET(gtk_builder_get_object(builder, "player_window"));
+ player = GTK_WIDGET(gtk_builder_get_object(builder, "player_widget"));
- player = gtk_vlc_player_new();
- gtk_container_add(GTK_CONTAINER(window), player);
+ g_object_unref(builder);
gtk_vlc_player_load(GTK_VLC_PLAYER(player), argv[1]);
- gtk_vlc_player_play(GTK_VLC_PLAYER(player));
gtk_widget_show_all(window);