added filechooser
authorVlad <vlad@gas.by>
Wed, 28 Jul 2010 10:21:23 +0000 (13:21 +0300)
committerVlad <vlad@gas.by>
Wed, 28 Jul 2010 10:21:23 +0000 (13:21 +0300)
applet/configure.ac
applet/debian/control
applet/src/livewp-common.h
applet/src/livewp-main.c
applet/src/livewp-scene.c
applet/src/livewp-scene.h
applet/src/livewp-settings.c
applet/src/livewp-settings.h

index 9f7d4ad..7a120ba 100644 (file)
@@ -12,7 +12,7 @@ AC_HEADER_STDC
 AC_PROG_INSTALL
 AM_PROG_LIBTOOL
 
-PKG_CHECK_MODULES(EXAMPLE, hildon-1 libhildondesktop-1 gtk+-2.0 gstreamer-0.10)
+PKG_CHECK_MODULES(EXAMPLE, hildon-1 libhildondesktop-1 hildon-fm-2 gtk+-2.0 gstreamer-0.10)
 AC_SUBST(EXAMPLE_CFLAGS)
 AC_SUBST(EXAMPLE_LIBS)
 
index 5474ca9..3e80391 100644 (file)
@@ -2,7 +2,7 @@ Source: live-wallpaper
 Section: user/desktop
 Priority: optional
 Maintainer: Vlad Vasiliev vlad@gas.by
-Build-Depends: debhelper (>= 5), autotools-dev, libhildondesktop1-dev (>= 2.1.16), libosso-dev (>= 1), hildon-control-panel-dev, libsqlite3-dev, libgstreamer0.10-dev
+Build-Depends: debhelper (>= 5), autotools-dev, libhildondesktop1-dev (>= 2.1.16), libosso-dev (>= 1), hildon-control-panel-dev, libsqlite3-dev, libgstreamer0.10-dev, libgstreamer-plugins-base0.10-dev
 Standards-Version: 3.7.2
 
 Package: live-wallpaper
index fad4728..122ca68 100644 (file)
@@ -39,6 +39,9 @@
 #include <gdk/gdkx.h>
 
 #include <X11/Xatom.h>
+/* Gstreamer */
+#include <gst/gst.h>
+#include <gst/interfaces/xoverlay.h>
 
 #define GETTEXT_PACKAGE "livewp"
 #include <glib/gi18n-lib.h>
@@ -101,6 +104,7 @@ struct _Animation_WallpaperPrivate
     guint alive_timer;
     time_t last_alive_event;
     gchar *theme_string_parametr1;
+    GstElement *pipeline;
 };
 
 struct _AWallpaperPlugin
index 15eb491..9497fe4 100644 (file)
@@ -70,11 +70,16 @@ void
 view_state_changed (Animation_WallpaperPrivate *priv)
 {
    if (priv->visible){
+       if (priv->pipeline)
+            gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
        if (priv->long_timer == 0 ){
             priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, priv->desktop_plugin);
             run_long_timeout(priv->desktop_plugin);
        }
    }else{
+        if (priv->pipeline){
+            gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+        }
         if (priv->long_timer != 0 ){
             g_source_remove(priv->long_timer);
             priv->long_timer = 0;
@@ -189,6 +194,7 @@ main(int argc, char *argv[])
     g_hash_table_insert(priv->hash_scene_func, g_strdup("Video"),  (gpointer)&init_scene_Video);
 
     priv->scene = NULL;
+    priv->pipeline = NULL;
     priv->window = main_widget;
     fprintf(stderr,"XWINDOW %i\n",GDK_WINDOW_XID (main_widget->window));
     priv->desktop_plugin = desktop_plugin;
index d88128e..90a4fa3 100644 (file)
@@ -1,4 +1,4 @@
-/*vim: set sw=4 ts=4 et: */
+/* vim: set sw=4 ts=4 et: */
 /*
  * This file is part of Live Wallpaper (livewp)
  * 
@@ -65,38 +65,48 @@ parsestring(char *line, char **argv)
                  *argv = '\0';                 /* mark the end of argument list  */
 }
 
+#if 0
+GstBusSyncReply 
+sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
+
+    if (!desktop_plugin->priv->visible)
+        gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
+    if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
+               return (GST_BUS_PASS);
+       }
+    if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
+        return (GST_BUS_PASS);
+    }
+    return (GST_BUS_DROP);
 
+}
+#endif
 void
 init_scene_Video(AWallpaperPlugin *desktop_plugin)
 {
-    GstElement *pipeline;                                                                                                                    
     GstElement *bin;                                                                                                                                                           
     GstElement *videosink;                                                                                                
     GstFormat format; 
 
 
 
-    fprintf(stderr,"dddddddddddddddddddd\n");
-    pipeline= gst_pipeline_new("gst-player");
+    desktop_plugin->priv->pipeline= gst_pipeline_new("gst-player");
     bin = gst_element_factory_make ("playbin2", "bin");
     videosink = gst_element_factory_make ("ximagesink", "videosink");
     g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
-    gst_bin_add (GST_BIN (pipeline), bin);
+    gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
 
     {
        GstBus *bus;
-       bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+       bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
 //     gst_bus_add_watch(bus, bus_call, NULL);
-//     gst_bus_set_sync_handler(bus, (GstBusSyncHandler)SetVideoAreaXID, desktop_plugin);
        gst_object_unref (bus);
     }
     g_object_set (G_OBJECT (bin), "uri", "file:///home/user/MyDocs/.videos/9.mp4", NULL );
     g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL  );
-    if (GST_IS_X_OVERLAY (videosink)){
-           printf("Is Overlay (Win ID: %i)!!\n",GPOINTER_TO_INT(GDK_WINDOW_XWINDOW(desktop_plugin->priv->window->window)));
+    if (GST_IS_X_OVERLAY (videosink))
            gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
-    }
-    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
 }
 
 void
index c1c9034..1f89654 100644 (file)
@@ -30,9 +30,6 @@
 #include <sys/time.h>
 #include "livewp-rules.h"
 #include <glib-object.h>
-/* Gstreamer */
-#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
 
 
 
index 4dd85e9..d88fe5f 100644 (file)
@@ -190,6 +190,7 @@ lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
 
     window = gtk_dialog_new();
 
+    priv->window = window;
     gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
     gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
     gtk_window_set_modal(GTK_WINDOW(window), TRUE);
@@ -230,7 +231,47 @@ lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
     if (window)
         gtk_widget_destroy(window);
 }
+/*******************************************************************************/
+void
+file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
+
+    GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_OPEN);
+
+    if (priv->theme_string_parametr1)
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
+
+    gtk_widget_show_all (GTK_WIDGET (dialog));
 
+    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+    {
+      if (priv->theme_string_parametr1)
+            g_free(priv->theme_string_parametr1);
+       priv->theme_string_parametr1 = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+       hildon_button_set_value (button, priv->theme_string_parametr1);
+    }
+    gtk_widget_destroy (dialog);
+
+}
+/*******************************************************************************/
+void
+additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
+
+    GtkWidget *file_button;
+
+    if (priv->theme_string_parametr1)
+        file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                                                   _("Play file"), priv->theme_string_parametr1);
+    else
+        file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                                                   _("Play file"),"");
+
+    g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
+
+    gtk_box_pack_start(GTK_BOX(vbox),
+                                   file_button, TRUE, TRUE, 5);
+    gtk_widget_show (file_button);
+
+}
 /*******************************************************************************/
 void 
 lw_theme_settings(Animation_WallpaperPrivate *priv, GtkWidget *button){
@@ -239,6 +280,7 @@ lw_theme_settings(Animation_WallpaperPrivate *priv, GtkWidget *button){
     GtkWidget *save_button;
     GtkWidget *theme_button;
     GtkWidget *enable_button;
+    GtkWidget *vbox;
     GtkWidget *rich_animation_button;
     gint view = priv->view;
 
@@ -259,9 +301,19 @@ lw_theme_settings(Animation_WallpaperPrivate *priv, GtkWidget *button){
     rich_animation_button = create_rich_animation_button(priv->rich_animation);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
                                    rich_animation_button, TRUE, TRUE, 5);
+     
+    /* Create custom vbox */
+    vbox = gtk_vbox_new (FALSE, 5);
+    g_object_set_data(G_OBJECT(window), "custom_vbox", vbox);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
+                                   vbox, TRUE, TRUE, 5);
+    if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
+        additional_parametr_for_theme_video(vbox, priv);
+    } 
     gtk_widget_show (enable_button);
     gtk_widget_show (theme_button);
     gtk_widget_show (rich_animation_button);
+    gtk_widget_show (vbox);
     gtk_widget_show (window);
     save_button = gtk_dialog_add_button(GTK_DIALOG(window), _("Save"), GTK_RESPONSE_YES);
 
@@ -274,9 +326,6 @@ lw_theme_settings(Animation_WallpaperPrivate *priv, GtkWidget *button){
 
                 if (priv->theme)
                     g_free(priv->theme);
-                if (priv->theme_string_parametr1)
-                    g_free(priv->theme_string_parametr1);
-                priv->theme_string_parametr1 = NULL;
 
                 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
                     priv->theme = g_strdup("Berlin");
@@ -286,7 +335,6 @@ lw_theme_settings(Animation_WallpaperPrivate *priv, GtkWidget *button){
                     priv->theme = g_strdup("Matrix");
                 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
                     priv->theme = g_strdup("Video");
-                    priv->theme_string_parametr1 = g_strdup("/home/user/MyDocs/.videos/9.mp4");
                 }
 
             }
index 1e37988..0b5cc39 100644 (file)
@@ -23,6 +23,7 @@
 */
 /*******************************************************************************/
 #include "livewp-common.h"
+#include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
 #include <unistd.h>
 void lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data);
 void save_config(Animation_WallpaperPrivate *priv);