[cheese] window: restore the infobar
- From: Filippo Argiolas <fargiolas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] window: restore the infobar
- Date: Sun, 21 Feb 2010 21:38:06 +0000 (UTC)
commit 84b8e1a76a04d88b158b60d5b4dd34483135ee86
Author: Filippo Argiolas <filippo argiolas gmail com>
Date: Sun Feb 21 21:59:56 2010 +0100
window: restore the infobar
Restore the infobar temporarily removed while reorganizing
cheese-window.c. Use it to display generic camera initialization errors
instead of just the no-device one.
src/cheese-no-camera.c | 4 ++-
src/cheese-no-camera.h | 4 ++
src/cheese-ui.h | 6 ++-
src/cheese-window.c | 82 +++++++++++++++++++++++++++++++++++++++++------
4 files changed, 82 insertions(+), 14 deletions(-)
---
diff --git a/src/cheese-no-camera.c b/src/cheese-no-camera.c
index 6c1a37f..aabca08 100644
--- a/src/cheese-no-camera.c
+++ b/src/cheese-no-camera.c
@@ -28,7 +28,7 @@
#include "cheese-no-camera.h"
-static void
+void
cheese_no_camera_set_info_bar_text_and_icon (GtkInfoBar *info_bar,
const gchar *icon_stock_id,
const gchar *primary_text,
@@ -88,10 +88,12 @@ cheese_no_camera_info_bar_new ()
info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
GTK_MESSAGE_WARNING);
+#if 0
cheese_no_camera_set_info_bar_text_and_icon (GTK_INFO_BAR (info_bar),
"gtk-dialog-error",
_("No camera found!"),
_("Please refer to the help for further information."));
+#endif
return info_bar;
}
diff --git a/src/cheese-no-camera.h b/src/cheese-no-camera.h
index 3d97993..d383f29 100644
--- a/src/cheese-no-camera.h
+++ b/src/cheese-no-camera.h
@@ -24,6 +24,10 @@
G_BEGIN_DECLS
GtkWidget *cheese_no_camera_info_bar_new (void);
+void cheese_no_camera_set_info_bar_text_and_icon (GtkInfoBar *info_bar,
+ const gchar *icon_stock_id,
+ const gchar *primary_text,
+ const gchar *secondary_text);
G_END_DECLS
diff --git a/src/cheese-ui.h b/src/cheese-ui.h
index c9c76bb..129e828 100644
--- a/src/cheese-ui.h
+++ b/src/cheese-ui.h
@@ -32,8 +32,6 @@ const GtkActionEntry action_entries_main[] = {
{"Cheese", NULL, N_("_Cheese") },
{"Edit", NULL, N_("_Edit") },
- {"Preferences", GTK_STOCK_PREFERENCES, N_("Preferences"), NULL, NULL, G_CALLBACK (cheese_window_preferences_cb)},
-
{"Help", NULL, N_("_Help") },
{"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (cheese_cmd_quit)},
@@ -42,6 +40,10 @@ const GtkActionEntry action_entries_main[] = {
{"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK (cheese_cmd_about)},
};
+const GtkActionEntry action_entries_prefs[] = {
+ {"Preferences", GTK_STOCK_PREFERENCES, N_("Preferences"), NULL, NULL, G_CALLBACK (cheese_window_preferences_cb)},
+};
+
const GtkRadioActionEntry action_entries_toggle[] = {
{"Photo", NULL, N_("_Photo"), NULL, NULL, 0},
{"Video", NULL, N_("_Video"), NULL, NULL, 1},
diff --git a/src/cheese-window.c b/src/cheese-window.c
index e1c672e..58a3c10 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -112,6 +112,7 @@ typedef struct
GtkWidget *netbook_alignment;
GtkWidget *toolbar_alignment;
GtkWidget *effect_button_alignment;
+ GtkWidget *info_bar_alignment;
GtkWidget *togglegroup_alignment;
GtkWidget *effect_frame;
@@ -121,6 +122,7 @@ typedef struct
GtkWidget *throbber_align;
GtkWidget *throbber_box;
GtkWidget *throbber;
+ GtkWidget *info_bar;
GtkWidget *countdown_frame;
GtkWidget *countdown_frame_fullscreen;
GtkWidget *countdown;
@@ -154,10 +156,11 @@ typedef struct
GtkWidget *take_picture;
GtkWidget *take_picture_fullscreen;
+ GtkActionGroup *actions_main;
+ GtkActionGroup *actions_prefs;
GtkActionGroup *actions_countdown;
GtkActionGroup *actions_effects;
GtkActionGroup *actions_file;
- GtkActionGroup *actions_main;
GtkActionGroup *actions_photo;
GtkActionGroup *actions_toggle;
GtkActionGroup *actions_video;
@@ -327,7 +330,10 @@ cheese_window_toggle_fullscreen (GtkWidget *widget, CheeseWindow *cheese_window)
}
else
{
- gtk_widget_show_all (GTK_WIDGET (cheese_window));
+ gtk_widget_show (priv->thumb_view);
+ gtk_widget_show (priv->thumb_scrollwindow);
+ gtk_widget_show (menubar);
+ gtk_widget_show (priv->notebook_bar);
gtk_widget_hide_all (priv->fullscreen_popup);
gtk_widget_modify_bg (GTK_WIDGET (cheese_window), GTK_STATE_NORMAL, NULL);
@@ -629,7 +635,6 @@ cheese_window_countdown_picture_cb (gpointer data)
g_free (photo_filename);
}
-#if 0
static void
cheese_window_no_camera_info_bar_response (GtkWidget *widget, gint response_id, CheeseWindow *cheese_window)
{
@@ -653,7 +658,6 @@ cheese_window_no_camera_info_bar_response (GtkWidget *widget, gint response_id,
}
}
}
-#endif
static void
cheese_window_stop_recording (CheeseWindow *cheese_window)
@@ -1043,6 +1047,7 @@ setup_widgets_from_builder (CheeseWindow *cheese_window)
priv->netbook_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "netbook_alignment"));
priv->togglegroup_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "togglegroup_alignment"));
priv->effect_button_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "effect_button_alignment"));
+ priv->info_bar_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "info_bar_alignment"));
priv->toolbar_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar_alignment"));
priv->video_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "video_vbox"));
priv->widget_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "widget_alignment"));
@@ -1087,6 +1092,10 @@ setup_menubar_and_actions (CheeseWindow *cheese_window)
"ActionsMain",
action_entries_main,
G_N_ELEMENTS (action_entries_main));
+ priv->actions_prefs = cheese_window_action_group_new (cheese_window,
+ "ActionsPrefs",
+ action_entries_prefs,
+ G_N_ELEMENTS (action_entries_prefs));
priv->actions_toggle = cheese_window_radio_action_group_new (cheese_window,
"ActionsRadio",
@@ -1193,9 +1202,29 @@ setup_menubar_and_actions (CheeseWindow *cheese_window)
}
static void
-ready_cb (CheeseWidget *widget,
- gboolean is_ready,
- CheeseWindow *window)
+on_widget_error (CheeseWidget *widget,
+ CheeseWindow *window)
+{
+ CheeseWindowPrivate *priv = CHEESE_WINDOW_GET_PRIVATE (window);
+ GError *error = NULL;
+
+ cheese_widget_get_error (widget, &error);
+ g_return_if_fail (error != NULL);
+
+ /* FIXME: hotplug new devices and hide the info bar */
+ gtk_action_group_set_sensitive (priv->actions_prefs, FALSE);
+ cheese_no_camera_set_info_bar_text_and_icon (GTK_INFO_BAR (priv->info_bar),
+ "gtk-dialog-error",
+ error->message,
+ _("Please refer to the help for further information."));
+ gtk_widget_show (priv->info_bar);
+
+ g_error_free (error);
+}
+
+static void
+on_widget_ready (CheeseWidget *widget,
+ CheeseWindow *window)
{
CheeseWindowPrivate *priv = CHEESE_WINDOW_GET_PRIVATE (window);
@@ -1214,6 +1243,28 @@ ready_cb (CheeseWidget *widget,
cheese_effect_chooser_get_selection (CHEESE_EFFECT_CHOOSER (priv->effect_chooser)));
}
+static void
+widget_state_change_cb (GObject *object,
+ GParamSpec *param_spec,
+ CheeseWindow *cheese_window)
+{
+ CheeseWidgetState state;
+ g_object_get (object, "state", &state, NULL);
+
+ switch (state) {
+ case CHEESE_WIDGET_STATE_READY:
+ on_widget_ready (CHEESE_WIDGET (object), cheese_window);
+ break;
+ case CHEESE_WIDGET_STATE_ERROR:
+ on_widget_error (CHEESE_WIDGET (object), cheese_window);
+ break;
+ case CHEESE_WIDGET_STATE_NONE:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
void
cheese_window_init (CheeseWindow *cheese_window)
{
@@ -1235,12 +1286,21 @@ cheese_window_init (CheeseWindow *cheese_window)
setup_widgets_from_builder (cheese_window);
setup_menubar_and_actions (cheese_window);
- g_signal_connect (G_OBJECT (priv->thewidget), "ready",
- G_CALLBACK (ready_cb), cheese_window);
+ priv->info_bar = cheese_no_camera_info_bar_new ();
+ gtk_container_add (GTK_CONTAINER (priv->info_bar_alignment), priv->info_bar);
+
+ g_signal_connect (priv->info_bar,
+ "response",
+ G_CALLBACK (cheese_window_no_camera_info_bar_response),
+ cheese_window);
+
+ g_signal_connect (G_OBJECT (priv->thewidget), "notify::state",
+ G_CALLBACK (widget_state_change_cb), cheese_window);
gtk_container_add (GTK_CONTAINER (priv->widget_alignment), priv->thewidget);
gtk_widget_show (priv->thewidget);
+
/* configure the popup position and size */
GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (priv->fullscreen_popup));
gtk_window_set_default_size (GTK_WINDOW (priv->fullscreen_popup),
@@ -1271,6 +1331,7 @@ cheese_window_init (CheeseWindow *cheese_window)
g_object_get (priv->gconf, "gconf_prop_selected_effects", &gconf_effects, NULL);
priv->effect_chooser = cheese_effect_chooser_new (gconf_effects);
gtk_container_add (GTK_CONTAINER (priv->effect_frame), priv->effect_chooser);
+ gtk_widget_show_all (priv->effect_vbox);
g_free (gconf_effects);
priv->countdown = cheese_countdown_new ();
@@ -1339,8 +1400,6 @@ cheese_window_constructed (GObject *object)
gtk_window_resize (GTK_WINDOW (window), req.width, req.height);
gtk_widget_set_size_request (priv->thewidget, -1, -1);
- gtk_widget_show_all (priv->main_vbox);
-
if (G_OBJECT_CLASS (cheese_window_parent_class)->constructed)
G_OBJECT_CLASS (cheese_window_parent_class)->constructed (object);
}
@@ -1368,6 +1427,7 @@ cheese_window_finalize (GObject *object)
g_object_unref (priv->fileutil);
g_object_unref (priv->actions_main);
+ g_object_unref (priv->actions_prefs);
g_object_unref (priv->actions_countdown);
g_object_unref (priv->actions_effects);
g_object_unref (priv->actions_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]