[gnac/devel] Disabled main interface during plugins' installation



commit 1e5ed9dfe0589b0b2dda0a9fe1560dc6a533299e
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Sat May 29 21:03:50 2010 +0100

    Disabled main interface during plugins' installation

 libgnac/libgnac-converter.c  |   16 ++++++++++++++++
 libgnac/libgnac-converter.h  |    4 ++++
 libgnac/libgnac-media-item.c |    2 ++
 src/gnac-bars.c              |   36 ++++++++++++++++++++++++++++++++++++
 src/gnac-bars.h              |    9 +++++++++
 src/gnac-main.c              |   32 +++++++++++++++++++++++++-------
 src/gnac-main.h              |    3 ++-
 7 files changed, 94 insertions(+), 8 deletions(-)
---
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index 77b7389..f4c21a6 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -50,6 +50,7 @@ enum
   STARTED,
   STOPPED,
   COMPLETION,
+  PLUGIN_INSTALL,
   ERROR,
   LAST_SIGNAL
 };
@@ -540,6 +541,14 @@ libgnac_converter_class_init(LibgnacConverterClass *klass)
       g_cclosure_marshal_VOID__VOID,
       G_TYPE_NONE, 0);
 
+  signals[PLUGIN_INSTALL] = g_signal_new("plugin-install",
+      G_TYPE_FROM_CLASS(gobject_class),
+      G_SIGNAL_RUN_LAST,
+      G_STRUCT_OFFSET(LibgnacConverterClass, plugin_install),
+      NULL, NULL,
+      g_cclosure_marshal_VOID__VOID,
+      G_TYPE_NONE, 0);
+
   signals[ERROR] = g_signal_new("error",
       G_TYPE_FROM_CLASS(gobject_class),
       G_SIGNAL_RUN_LAST,
@@ -870,6 +879,13 @@ libgnac_converter_resume(LibgnacConverter  *self,
 }
 
 
+void
+libgnac_converter_emit_plugin_install(LibgnacConverter *self)
+{
+  g_signal_emit(self, signals[PLUGIN_INSTALL], 0);
+}
+
+
 /* Callbacks */
 void
 libgnac_converter_eos_cb(GstBus     *bus, 
diff --git a/libgnac/libgnac-converter.h b/libgnac/libgnac-converter.h
index 0c95134..944cd50 100644
--- a/libgnac/libgnac-converter.h
+++ b/libgnac/libgnac-converter.h
@@ -82,6 +82,7 @@ typedef struct
   void (*started) (LibgnacConverter *converter);
   void (*stopped) (LibgnacConverter *converter);
   void (*completion) (LibgnacConverter *converter);
+  void (*plugin_install) (LibgnacConverter *converter);
   void (*error) (LibgnacConverter *converter, gchar *uri, gchar *msg, GError *error);
 
 } LibgnacConverterClass;
@@ -125,6 +126,9 @@ void
 libgnac_converter_resume(LibgnacConverter  *self,
                          GError           **error);
 
+void
+libgnac_converter_emit_plugin_install(LibgnacConverter *converter);
+
 /* Callbacks */
 
 void
diff --git a/libgnac/libgnac-media-item.c b/libgnac/libgnac-media-item.c
index 13c692c..c8827c6 100644
--- a/libgnac/libgnac-media-item.c
+++ b/libgnac/libgnac-media-item.c
@@ -117,6 +117,8 @@ libgnac_item_build(LibgnacMediaItem  *item,
         g_free(detail);
         if (ret != GST_INSTALL_PLUGINS_STARTED_OK) {
           libgnac_warning("Could not launch installer for required plugins");
+        } else {
+          libgnac_converter_emit_plugin_install(item->parent);
         }
       }
       return;
diff --git a/src/gnac-bars.c b/src/gnac-bars.c
index 23d155b..1eb9b06 100644
--- a/src/gnac-bars.c
+++ b/src/gnac-bars.c
@@ -205,6 +205,19 @@ gnac_bars_on_convert_resume(void)
 
 
 void
+gnac_bars_on_plugin_install(void)
+{
+  gnac_bars_activate_add(FALSE);
+  gnac_bars_activate_clear(FALSE);
+  gnac_bars_activate_convert(FALSE);
+  gnac_bars_activate_pause(FALSE);
+  gnac_bars_activate_preferences(FALSE);
+  gnac_bars_activate_remove(FALSE);
+  gnac_bars_activate_quit(FALSE);
+}
+
+
+void
 gnac_bars_activate_properties(gboolean activate)
 {
   GtkAction *action;
@@ -261,3 +274,26 @@ gnac_bars_activate_preferences(gboolean activate)
   action = gnac_ui_get_action("prefs_item");
   gtk_action_set_sensitive(action, activate);
 }
+
+
+void
+gnac_bars_activate_convert(gboolean activate)
+{
+  GtkAction *action;
+  GtkWidget *widget;
+
+  action = gnac_ui_get_action("convert_item");
+  gtk_action_set_sensitive(action, activate);
+
+  widget = gnac_ui_get_widget("convert_button");
+  gtk_widget_set_sensitive(widget, activate);
+}
+
+
+void
+gnac_bars_activate_quit(gboolean activate)
+{
+  GtkAction *action;
+  action = gnac_ui_get_action("quit_item");
+  gtk_action_set_sensitive(action, activate);
+}
diff --git a/src/gnac-bars.h b/src/gnac-bars.h
index e76ec2e..4a1b710 100644
--- a/src/gnac-bars.h
+++ b/src/gnac-bars.h
@@ -60,6 +60,9 @@ gnac_bars_on_convert_pause(void);
 void
 gnac_bars_on_convert_resume(void);
 
+void
+gnac_bars_on_plugin_install(void);
+
 void 
 gnac_bars_activate_properties(gboolean activate);
 
@@ -78,6 +81,12 @@ gnac_bars_activate_clear(gboolean activate);
 void
 gnac_bars_activate_preferences(gboolean activate);
 
+void
+gnac_bars_activate_convert(gboolean activate);
+
+void
+gnac_bars_activate_quit(gboolean activate);
+
 G_END_DECLS
 
 #endif /* GNAC_BARS_H */
diff --git a/src/gnac-main.c b/src/gnac-main.c
index ce0d211..7803aae 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -77,12 +77,13 @@ GnacState                prev_state;
 LibgnacMetadata         *metadata;
 
 static const gchar *states[] = {
-    "GNAC_AUDIO_EMPTY_STATE",
-    "GNAC_AUDIO_FILE_ACTION_STATE",
-    "GNAC_AUDIO_READY_STATE",
-    "GNAC_AUDIO_CLEAR_STATE",
-    "GNAC_AUDIO_CONVERT_STATE",
-    "GNAC_AUDIO_PAUSED_STATE"
+  "GNAC_AUDIO_EMPTY_STATE",
+  "GNAC_AUDIO_FILE_ACTION_STATE",
+  "GNAC_AUDIO_READY_STATE",
+  "GNAC_AUDIO_CLEAR_STATE",
+  "GNAC_AUDIO_CONVERT_STATE",
+  "GNAC_AUDIO_PAUSED_STATE",
+  "GNAC_PLUGIN_INSTALL_STATE"
 };
 
 
@@ -160,6 +161,10 @@ gnac_change_state(GnacState new_state)
       gnac_bars_on_convert_pause();
     break;
 
+    case GNAC_PLUGIN_INSTALL_STATE:
+      gnac_bars_on_plugin_install();
+    break;
+
   default:
     /* does nothing */
    break;
@@ -572,7 +577,10 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
                       gpointer   data)
 {
   GError *error = NULL;
-  if (state == GNAC_AUDIO_CONVERT_STATE ||
+
+  if (state == GNAC_PLUGIN_INSTALL_STATE) {
+    return TRUE;
+  } else if (state == GNAC_AUDIO_CONVERT_STATE ||
       state == GNAC_AUDIO_PAUSED_STATE) 
   {
     if (!gnac_confirm_exit()) return TRUE;
@@ -923,6 +931,14 @@ gnac_on_converter_stopped_cb(LibgnacConverter *converter)
 
 
 static void
+gnac_on_converter_plugin_install_cb(LibgnacConverter *converter)
+{
+  gnac_change_state(GNAC_PLUGIN_INSTALL_STATE);
+  gnac_ui_push_status(_("Codec installer started"));
+}
+
+
+static void
 gnac_on_converter_error_cb(LibgnacConverter *converter,
                            const gchar      *uri,
                            const gchar      *msg,
@@ -1253,6 +1269,8 @@ main(gint    argc,
       G_CALLBACK(gnac_on_converter_started_cb), converter);
   g_signal_connect(converter, "stopped", 
       G_CALLBACK(gnac_on_converter_stopped_cb), converter);
+  g_signal_connect(converter, "plugin-install",
+      G_CALLBACK(gnac_on_converter_plugin_install_cb), converter);
 
   gnac_ui_show();
 
diff --git a/src/gnac-main.h b/src/gnac-main.h
index 3cf0792..bea7156 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -39,7 +39,8 @@ typedef enum {
   GNAC_AUDIO_READY_STATE,
   GNAC_AUDIO_CLEAR_STATE,
   GNAC_AUDIO_CONVERT_STATE,
-  GNAC_AUDIO_PAUSED_STATE
+  GNAC_AUDIO_PAUSED_STATE,
+  GNAC_PLUGIN_INSTALL_STATE
 } GnacState;
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]