[gnome-panel] fish: Port to GSettings
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] fish: Port to GSettings
- Date: Mon, 28 Mar 2011 21:16:32 +0000 (UTC)
commit 4916b40afe7e5f932b07947a39c7a2a9b128dbd3
Author: Vincent Untz <vuntz gnome org>
Date: Mon Mar 28 13:11:40 2011 +0530
fish: Port to GSettings
Note that the image that is being used is now defined in .fish files.
There's no UI to choose this right now; will be for 3.2.
applets/fish/Makefile.am | 27 +-
applets/fish/fish.c | 799 +++++---------------
applets/fish/fish.schemas.in | 91 ---
applets/fish/fish.ui | 158 +----
applets/fish/fishanim.fish | 3 +
applets/fish/footguy.fish | 3 +
applets/fish/monkey.fish | 3 +
applets/fish/oldwanda.fish | 3 +
applets/fish/wanda.fish | 3 +
data/org.gnome.gnome-panel.applet.fish.gschema.xml | 8 +-
10 files changed, 227 insertions(+), 871 deletions(-)
---
diff --git a/applets/fish/Makefile.am b/applets/fish/Makefile.am
index bdcb6db..4b8912b 100644
--- a/applets/fish/Makefile.am
+++ b/applets/fish/Makefile.am
@@ -65,10 +65,15 @@ endif
fishbitmapsdir = $(datadir)/gnome-panel/pixmaps
fishbitmaps_DATA = \
+ wanda.fish \
wanda.png \
+ fishanim.fish \
fishanim.png \
+ oldwanda.fish \
oldwanda.png \
+ footguy.fish \
footguy.png \
+ monkey.fish \
monkey.png
uidir = $(datadir)/gnome-panel/ui
@@ -77,34 +82,14 @@ ui_DATA = fish.ui
xmluidir = $(datadir)/gnome-panel/ui
xmlui_DATA = fish-menu.xml
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = fish.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
-
- INTLTOOL_SCHEMAS_RULE@
-
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/applets/fish/$$p ; \
- done \
- fi
-uninstall-local:
- for p in $(schema_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $(top_builddir)/applets/fish/$$p ; \
- done
-endif
-
EXTRA_DIST = \
wanda.svg \
$(fishbitmaps_DATA) \
org.gnome.panel.FishApplet.panel-applet.in.in \
$(service_in_files) \
- fish.schemas.in \
$(ui_DATA) \
$(xmlui_DATA)
-CLEANFILES = $(schemas_DATA) $(applet_DATA) $(applet_DATA).in $(service_DATA)
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
-include $(top_srcdir)/git.mk
diff --git a/applets/fish/fish.c b/applets/fish/fish.c
index e2ae89c..4240dd4 100644
--- a/applets/fish/fish.c
+++ b/applets/fish/fish.c
@@ -39,8 +39,6 @@
#include <gdk/gdkkeysyms.h>
#include <panel-applet.h>
-#include <panel-applet-gconf.h>
-#include <gconf/gconf-client.h>
#define FISH_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
fish_applet_get_type(), \
@@ -50,17 +48,24 @@
#define FISH_ICON "gnome-panel-fish"
-#define N_FISH_PREFS 6
+#define FISH_SCHEMA "org.gnome.gnome-panel.applet.fish"
+#define FISH_NAME_KEY "name"
+#define FISH_IMAGE_KEY "image"
+#define FISH_COMMAND_KEY "command"
+#define FISH_SPEED_KEY "speed"
+#define FISH_ROTATE_KEY "rotate"
+#define FISH_NAME_DEFAULT "Wanda"
+#define FISH_IMAGE_DEFAULT "wanda.fish"
+#define FISH_SPEED_DEFAULT 0.3
-#define LOCKDOWN_COMMANDLINE_KEY "/desktop/gnome/lockdown/disable_command_line"
-#define N_FISH_LOCKDOWN 1
-
-#define N_FISH_LISTENERS (N_FISH_PREFS + N_FISH_LOCKDOWN)
+#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown"
+#define LOCKDOWN_COMMANDLINE_KEY "disable-command-line"
typedef struct {
PanelApplet applet;
- GConfClient *client;
+ GSettings *settings;
+ GSettings *lockdown_settings;
char *name;
char *image;
@@ -83,14 +88,6 @@ typedef struct {
GdkPixbuf *pixbuf;
GtkWidget *preferences_dialog;
- GtkWidget *name_entry;
- GtkWidget *command_label;
- GtkWidget *command_entry;
- GtkWidget *preview_image;
- GtkWidget *image_chooser;
- GtkWidget *frames_spin;
- GtkWidget *speed_spin;
- GtkWidget *rotate_toggle;
GtkWidget *fortune_dialog;
GtkWidget *fortune_view;
@@ -102,8 +99,6 @@ typedef struct {
GIOChannel *io_channel;
gboolean april_fools;
-
- guint listeners [N_FISH_LISTENERS];
} FishApplet;
typedef struct {
@@ -198,56 +193,6 @@ show_help (FishApplet *fish, const char *link_id)
}
static void
-name_value_changed (GtkEntry *entry,
- FishApplet *fish)
-{
- const char *text;
-
- text = gtk_entry_get_text (entry);
-
- if (!text || !text [0])
- return;
-
- panel_applet_gconf_set_string (
- PANEL_APPLET (fish), "name", text, NULL);
-}
-
-static void
-image_value_changed (GtkFileChooser *chooser,
- FishApplet *fish)
-{ char *path;
- char *image;
- char *path_gconf;
-
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-
- if (!path || !path[0]) {
- g_free (path);
- return;
- }
-
- path_gconf = get_image_path (fish);
- if (!strcmp (path, path_gconf)) {
- g_free (path);
- g_free (path_gconf);
- return;
- }
- g_free (path_gconf);
-
- if (!strncmp (path, FISH_ICONDIR, strlen (FISH_ICONDIR))) {
- image = path + strlen (FISH_ICONDIR);
- while (*image && *image == G_DIR_SEPARATOR)
- image++;
- } else
- image = path;
-
- panel_applet_gconf_set_string (PANEL_APPLET (fish), "image",
- image, NULL);
-
- g_free (path);
-}
-
-static void
command_value_changed (GtkEntry *entry,
FishApplet *fish)
{
@@ -256,8 +201,7 @@ command_value_changed (GtkEntry *entry,
text = gtk_entry_get_text (entry);
if (!text || !text [0]) {
- panel_applet_gconf_set_string (PANEL_APPLET (fish),
- "command", "", NULL);
+ g_settings_set_string (fish->settings, FISH_COMMAND_KEY, "");
return;
}
@@ -290,35 +234,7 @@ command_value_changed (GtkEntry *entry,
}
}
- panel_applet_gconf_set_string (
- PANEL_APPLET (fish), "command", text, NULL);
-}
-
-static void
-n_frames_value_changed (GtkSpinButton *button,
- FishApplet *fish)
-{
- panel_applet_gconf_set_int (
- PANEL_APPLET (fish), "frames",
- gtk_spin_button_get_value_as_int (button), NULL);
-}
-
-static void
-speed_value_changed (GtkSpinButton *button,
- FishApplet *fish)
-{
- panel_applet_gconf_set_float (
- PANEL_APPLET (fish), "speed",
- gtk_spin_button_get_value (button), NULL);
-}
-
-static void
-rotate_value_changed (GtkToggleButton *toggle,
- FishApplet *fish)
-{
- panel_applet_gconf_set_bool (
- PANEL_APPLET (fish), "rotate",
- gtk_toggle_button_get_active (toggle), NULL);
+ g_settings_set_string (fish->settings, FISH_COMMAND_KEY, text);
}
static gboolean
@@ -343,80 +259,18 @@ handle_response (GtkWidget *widget,
gtk_widget_hide (fish->preferences_dialog);
}
-static void
-setup_sensitivity (FishApplet *fish,
- GtkBuilder *builder,
- const char *wid,
- const char *label,
- const char *label_post,
- const char *key)
-{
- PanelApplet *applet = (PanelApplet *) fish;
- char *fullkey;
- GtkWidget *w;
-
- fullkey = panel_applet_gconf_get_full_key (applet, key);
-
- if (gconf_client_key_is_writable (fish->client, fullkey, NULL)) {
- g_free (fullkey);
- return;
- }
- g_free (fullkey);
-
- w = GTK_WIDGET (gtk_builder_get_object (builder, wid));
- g_assert (w != NULL);
- gtk_widget_set_sensitive (w, FALSE);
-
- if (label != NULL) {
- w = GTK_WIDGET (gtk_builder_get_object (builder, label));
- g_assert (w != NULL);
- gtk_widget_set_sensitive (w, FALSE);
- }
- if (label_post != NULL) {
- w = GTK_WIDGET (gtk_builder_get_object (builder, label_post));
- g_assert (w != NULL);
- gtk_widget_set_sensitive (w, FALSE);
- }
-
-}
-
-static void
-chooser_preview_update (GtkFileChooser *file_chooser,
- gpointer data)
-{
- GtkWidget *preview;
- char *filename;
- GdkPixbuf *pixbuf;
- gboolean have_preview;
-
- preview = GTK_WIDGET (data);
- filename = gtk_file_chooser_get_preview_filename (file_chooser);
-
- if (filename == NULL)
- return;
-
- pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
- have_preview = (pixbuf != NULL);
- g_free (filename);
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
- if (pixbuf)
- g_object_unref (pixbuf);
-
- gtk_file_chooser_set_preview_widget_active (file_chooser,
- have_preview);
-}
-
static void
display_preferences_dialog (GtkAction *action,
FishApplet *fish)
{
- GtkBuilder *builder;
- GError *error;
- GtkWidget *button;
- GtkFileFilter *filter;
- GtkWidget *chooser_preview;
- char *path;
+ GtkBuilder *builder;
+ GError *error;
+ GtkWidget *box;
+ GtkWidget *name_entry;
+ GtkWidget *command_entry;
+ GtkWidget *speed_spin;
+ GtkWidget *rotate_toggle;
+ GtkWidget *button;
if (fish->preferences_dialog) {
gtk_window_set_screen (GTK_WINDOW (fish->preferences_dialog),
@@ -448,107 +302,43 @@ display_preferences_dialog (GtkAction *action,
gtk_dialog_set_default_response (
GTK_DIALOG (fish->preferences_dialog), GTK_RESPONSE_OK);
- fish->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
- gtk_entry_set_text (GTK_ENTRY (fish->name_entry), fish->name);
-
- g_signal_connect (fish->name_entry, "changed",
- G_CALLBACK (name_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "name_entry" /* wid */,
- "name_label" /* label */,
- NULL /* label_post */,
- "name" /* key */);
-
- fish->preview_image = GTK_WIDGET (gtk_builder_get_object (builder, "preview_image"));
- if (fish->pixbuf)
- gtk_image_set_from_pixbuf (GTK_IMAGE (fish->preview_image),
- fish->pixbuf);
-
- fish->image_chooser = GTK_WIDGET (gtk_builder_get_object (builder, "image_chooser"));
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Images"));
- gtk_file_filter_add_pixbuf_formats (filter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fish->image_chooser),
- filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fish->image_chooser),
- filter);
- chooser_preview = gtk_image_new ();
- gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (fish->image_chooser),
- chooser_preview);
- g_signal_connect (fish->image_chooser, "update-preview",
- G_CALLBACK (chooser_preview_update), chooser_preview);
- path = get_image_path (fish);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fish->image_chooser),
- path);
- g_free (path);
-
- g_signal_connect (fish->image_chooser, "selection-changed",
- G_CALLBACK (image_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "image_chooser" /* wid */,
- "image_label" /* label */,
- NULL /* label_post */,
- "image" /* key */);
-
- fish->command_label = GTK_WIDGET (gtk_builder_get_object (builder, "command_label"));
- fish->command_entry = GTK_WIDGET (gtk_builder_get_object (builder, "command_entry"));
- gtk_entry_set_text (GTK_ENTRY (fish->command_entry), fish->command);
-
- g_signal_connect (fish->command_entry, "changed",
+ name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
+ box = GTK_WIDGET (gtk_builder_get_object (builder, "name_box"));
+ g_settings_bind (fish->settings, FISH_NAME_KEY,
+ name_entry, "text",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_writable (fish->settings, FISH_NAME_KEY,
+ box, "sensitive",
+ FALSE);
+
+ command_entry = GTK_WIDGET (gtk_builder_get_object (builder, "command_entry"));
+ box = GTK_WIDGET (gtk_builder_get_object (builder, "command_box"));
+ g_settings_bind (fish->settings, FISH_COMMAND_KEY,
+ command_entry, "text",
+ G_SETTINGS_BIND_GET);
+ g_signal_connect (command_entry, "changed",
G_CALLBACK (command_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "command_entry" /* wid */,
- "command_label" /* label */,
- NULL /* label_post */,
- "command" /* key */);
-
- if (gconf_client_get_bool (fish->client,
- LOCKDOWN_COMMANDLINE_KEY,
- NULL)) {
- gtk_widget_set_sensitive (fish->command_label, FALSE);
- gtk_widget_set_sensitive (fish->command_entry, FALSE);
- }
-
- fish->frames_spin = GTK_WIDGET (gtk_builder_get_object (builder, "frames_spin"));
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->frames_spin),
- fish->n_frames);
-
- g_signal_connect (fish->frames_spin, "value_changed",
- G_CALLBACK (n_frames_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "frames_spin" /* wid */,
- "frames_label" /* label */,
- "frames_post_label" /* label_post */,
- "frames" /* key */);
-
- fish->speed_spin = GTK_WIDGET (gtk_builder_get_object (builder, "speed_spin"));
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin), fish->speed);
-
- g_signal_connect (fish->speed_spin, "value_changed",
- G_CALLBACK (speed_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "speed_spin" /* wid */,
- "speed_label" /* label */,
- "speed_post_label" /* label_post */,
- "speed" /* key */);
-
- fish->rotate_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_toggle"));
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (fish->rotate_toggle), fish->rotate);
-
- g_signal_connect (fish->rotate_toggle, "toggled",
- G_CALLBACK (rotate_value_changed), fish);
-
- setup_sensitivity (fish, builder,
- "rotate_toggle" /* wid */,
- NULL /* label */,
- NULL /* label_post */,
- "rotate" /* key */);
+ g_settings_bind_writable (fish->settings, FISH_COMMAND_KEY,
+ box, "sensitive",
+ FALSE);
+
+ g_settings_bind (fish->lockdown_settings, LOCKDOWN_COMMANDLINE_KEY,
+ box, "visible",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+ speed_spin = GTK_WIDGET (gtk_builder_get_object (builder, "speed_spin"));
+ box = GTK_WIDGET (gtk_builder_get_object (builder, "speed_box"));
+ g_settings_bind (fish->settings, FISH_SPEED_KEY,
+ speed_spin, "value",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_writable (fish->settings, FISH_SPEED_KEY,
+ box, "sensitive",
+ FALSE);
+
+ rotate_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_toggle"));
+ g_settings_bind (fish->settings, FISH_ROTATE_KEY,
+ rotate_toggle, "active",
+ G_SETTINGS_BIND_DEFAULT);
g_signal_connect (fish->preferences_dialog, "delete_event",
G_CALLBACK (delete_event), fish);
@@ -991,126 +781,6 @@ display_fortune_dialog (FishApplet *fish)
gtk_window_present (GTK_WINDOW (fish->fortune_dialog));
}
-static void
-name_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- const char *value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- value = gconf_value_get_string (entry->value);
-
- if (!value [0] || (fish->name && !strcmp (fish->name, value)))
- return;
-
- if (fish->name)
- g_free (fish->name);
- fish->name = g_strdup (value);
-
- update_fortune_dialog (fish);
- set_tooltip (fish);
- set_ally_name_desc (GTK_WIDGET (fish), fish);
-
- if (fish->name_entry &&
- strcmp (gtk_entry_get_text (GTK_ENTRY (fish->name_entry)), fish->name))
- gtk_entry_set_text (GTK_ENTRY (fish->name_entry), fish->name);
-}
-
-static void
-image_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- const char *value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- value = gconf_value_get_string (entry->value);
-
- if (!value [0] || (fish->image && !strcmp (fish->image, value)))
- return;
-
- if (fish->image)
- g_free (fish->image);
- fish->image = g_strdup (value);
-
- load_fish_image (fish);
- update_surface (fish);
-
- if (fish->image_chooser) {
- char *path_gconf;
- char *path_chooser;
-
- path_gconf = get_image_path (fish);
- path_chooser = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fish->image_chooser));
- if (strcmp (path_gconf, path_chooser))
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fish->image_chooser),
- path_gconf);
-
- g_free (path_gconf);
- g_free (path_chooser);
- }
-}
-
-static void
-command_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- const char *value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- value = gconf_value_get_string (entry->value);
-
- if (fish->command && !strcmp (fish->command, value))
- return;
-
- if (fish->command)
- g_free (fish->command);
- fish->command = g_strdup (value);
-
- if (fish->command_entry &&
- strcmp (gtk_entry_get_text (GTK_ENTRY (fish->command_entry)), fish->command))
- gtk_entry_set_text (GTK_ENTRY (fish->command_entry), fish->command);
-}
-
-static void
-n_frames_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- int value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_INT)
- return;
-
- value = gconf_value_get_int (entry->value);
-
- if (fish->n_frames == value)
- return;
-
- fish->n_frames = value;
-
- if (fish->n_frames <= 0)
- fish->n_frames = 1;
-
- update_surface (fish);
-
- if (fish->frames_spin &&
- gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (fish->frames_spin)) != fish->n_frames)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->frames_spin), fish->n_frames);
-}
-
static char *
get_location (void)
{
@@ -1240,134 +910,6 @@ setup_timeout (FishApplet *fish)
fish);
}
-static void
-speed_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- gdouble value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_FLOAT)
- return;
-
- value = gconf_value_get_float (entry->value);
-
- if (fish->speed == value)
- return;
- fish->speed = value;
-
- setup_timeout (fish);
-
- if (fish->speed_spin &&
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (fish->frames_spin)) != fish->speed)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin), fish->speed);
-}
-
-static void
-rotate_changed_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- gboolean value;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- value = gconf_value_get_bool (entry->value);
-
- if (fish->rotate == value)
- return;
- fish->rotate = value;
-
- if (fish->orientation == PANEL_APPLET_ORIENT_LEFT ||
- fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
- update_surface (fish);
-
- if (fish->rotate_toggle &&
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fish->rotate_toggle)) != fish->rotate)
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (fish->rotate_toggle), fish->rotate);
-}
-
-static void
-fish_disable_commande_line_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- FishApplet *fish)
-{
- gboolean locked_down;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- locked_down = !gconf_value_get_bool (entry->value);
-
- if (fish->command_label != NULL)
- gtk_widget_set_sensitive (fish->command_label, locked_down);
- if (fish->command_entry != NULL)
- gtk_widget_set_sensitive (fish->command_entry, locked_down);
-}
-
-static void
-setup_gconf (FishApplet *fish)
-{
- PanelApplet *applet = (PanelApplet *) fish;
- char *key;
- int i = 0;
-
- key = panel_applet_gconf_get_full_key (applet, "name");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) name_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- key = panel_applet_gconf_get_full_key (applet, "image");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) image_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- key = panel_applet_gconf_get_full_key (applet, "command");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) command_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- key = panel_applet_gconf_get_full_key (applet, "frames");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) n_frames_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- key = panel_applet_gconf_get_full_key (applet, "speed");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) speed_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- key = panel_applet_gconf_get_full_key (applet, "rotate");
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client, key,
- (GConfClientNotifyFunc) rotate_changed_notify,
- fish, NULL, NULL);
- g_free (key);
-
- fish->listeners [i++] = gconf_client_notify_add (
- fish->client,
- LOCKDOWN_COMMANDLINE_KEY,
- (GConfClientNotifyFunc) fish_disable_commande_line_notify,
- fish, NULL, NULL);
-
- g_assert (i == N_FISH_LISTENERS);
-}
-
static gboolean
load_fish_image (FishApplet *fish)
{
@@ -1392,10 +934,6 @@ load_fish_image (FishApplet *fish)
g_object_unref (fish->pixbuf);
fish->pixbuf = pixbuf;
- if (fish->preview_image)
- gtk_image_set_from_pixbuf (GTK_IMAGE (fish->preview_image),
- fish->pixbuf);
-
g_free (path);
return TRUE;
@@ -1769,11 +1307,6 @@ setup_fish_widget (FishApplet *fish)
update_surface (fish);
- setup_timeout (fish);
-
- set_tooltip (fish);
- set_ally_name_desc (GTK_WIDGET (fish), fish);
-
g_signal_connect (fish, "key_press_event",
G_CALLBACK (handle_keypress), fish);
@@ -1787,91 +1320,139 @@ static const GtkActionEntry fish_menu_verbs [] = {
};
static void
-fish_migrate_to_210 (FishApplet *fish)
+fish_applet_update_name (FishApplet *fish,
+ const char *name)
{
- char *new_image;
+ if (name[0] == '\0')
+ name = FISH_NAME_DEFAULT;
+ fish->name = g_strdup (name);
- g_assert (fish->image);
+ update_fortune_dialog (fish);
+ set_tooltip (fish);
+ set_ally_name_desc (GTK_WIDGET (fish), fish);
+}
- if (!strncmp (fish->image, "fish/", 5)) {
- new_image = g_strdup (fish->image + 5);
- g_free (fish->image);
- fish->image = new_image;
- panel_applet_gconf_set_string (PANEL_APPLET (fish), "image",
- fish->image, NULL);
+static void
+fish_applet_update_image (FishApplet *fish,
+ const char *image)
+{
+ char *keyfile_path;
+ GKeyFile *keyfile;
+
+ if (image[0] == '\0')
+ image = FISH_IMAGE_DEFAULT;
+ keyfile_path = g_build_filename (FISH_ICONDIR, image, NULL);
+
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_file (keyfile, keyfile_path,
+ G_KEY_FILE_NONE, NULL)) {
+ if (g_strcmp0 (image, FISH_IMAGE_DEFAULT) == 0) {
+ g_critical ("Cannot load default image ('%s')", image);
+ g_assert_not_reached ();
+ }
+
+ g_key_file_free (keyfile);
+ g_free (keyfile_path);
+
+ fish_applet_update_image (fish, FISH_IMAGE_DEFAULT);
+ return;
}
+
+ fish->image = g_key_file_get_string (keyfile, "Fish Animation",
+ "image", NULL);
+ fish->n_frames = g_key_file_get_integer (keyfile, "Fish Animation",
+ "frames", NULL);
+ if (fish->n_frames <= 0)
+ fish->n_frames = 1;
+
+ load_fish_image (fish);
+ update_surface (fish);
+
+ g_key_file_free (keyfile);
+ g_free (keyfile_path);
}
-static gboolean
-fish_applet_fill (FishApplet *fish)
+static void
+fish_applet_update_command (FishApplet *fish,
+ const char *command)
{
- PanelApplet *applet = (PanelApplet *) fish;
- GtkActionGroup *action_group;
- GtkAction *action;
- gchar *ui_path;
- GError *error = NULL;
+ g_free (fish->command);
+ fish->command = g_strdup (command);
+}
- fish->orientation = panel_applet_get_orient (applet);
+static void
+fish_applet_update_speed (FishApplet *fish,
+ gdouble speed)
+{
+ if (speed <= 0)
+ speed = FISH_SPEED_DEFAULT;
+ fish->speed = speed;
+ setup_timeout (fish);
+}
- panel_applet_add_preferences (
- applet, "/schemas/apps/fish_applet/prefs", NULL);
+static void
+fish_applet_update_rotate (FishApplet *fish,
+ gboolean rotate)
+{
+ fish->rotate = rotate;
- setup_gconf (fish);
+ if (fish->orientation == PANEL_APPLET_ORIENT_LEFT ||
+ fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
+ update_surface (fish);
+}
- fish->name = panel_applet_gconf_get_string (applet, "name", &error);
- if (error) {
- g_warning ("Error getting 'name' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
- }
- if (!fish->name)
- fish->name = g_strdup ("Wanda"); /* Fallback */
+static void
+fish_applet_settings_changed (GSettings *settings,
+ char *key,
+ FishApplet *fish)
+{
+ char *value_str = NULL;
+ gdouble value_double;
+ gboolean value_boolean;
- fish->image = panel_applet_gconf_get_string (applet, "image", &error);
- if (error) {
- g_warning ("Error getting 'image' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
- }
- if (!fish->image)
- fish->image = g_strdup ("fishanim.png"); /* Fallback */
- fish_migrate_to_210 (fish);
+ /* key == NULL is a locak hack to mean all keys */
- fish->command = panel_applet_gconf_get_string (applet, "command", &error);
- if (error) {
- g_warning ("Error getting 'command' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
+ if (!key || g_strcmp0 (key, FISH_NAME_KEY) == 0) {
+ value_str = g_settings_get_string (settings, FISH_NAME_KEY);
+ fish_applet_update_name (fish, value_str);
}
-
- fish->n_frames = panel_applet_gconf_get_int (applet, "frames", &error);
- if (error) {
- g_warning ("Error getting 'frames' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
-
- fish->n_frames = 3; /* Fallback */
+ if (!key || g_strcmp0 (key, FISH_IMAGE_KEY) == 0) {
+ value_str = g_settings_get_string (settings, FISH_IMAGE_KEY);
+ fish_applet_update_image (fish, value_str);
+ }
+ if (!key || g_strcmp0 (key, FISH_COMMAND_KEY) == 0) {
+ value_str = g_settings_get_string (settings, FISH_COMMAND_KEY);
+ fish_applet_update_command (fish, value_str);
+ }
+ if (!key || g_strcmp0 (key, FISH_SPEED_KEY) == 0) {
+ value_double = g_settings_get_double (settings, FISH_SPEED_KEY);
+ fish_applet_update_speed (fish, value_double);
+ }
+ if (!key || g_strcmp0 (key, FISH_ROTATE_KEY) == 0) {
+ value_boolean = g_settings_get_boolean (settings, FISH_ROTATE_KEY);
+ fish_applet_update_rotate (fish, value_boolean);
}
- if (fish->n_frames <= 0)
- fish->n_frames = 1;
- fish->speed = panel_applet_gconf_get_float (applet, "speed", &error);
- if (error) {
- g_warning ("Error getting 'speed' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
+ g_free (value_str);
+}
- fish->speed = 1.0; /* Fallback */
- }
+static gboolean
+fish_applet_fill (FishApplet *fish)
+{
+ PanelApplet *applet = (PanelApplet *) fish;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gchar *ui_path;
- fish->rotate = panel_applet_gconf_get_bool (applet, "rotate", &error);
- if (error) {
- g_warning ("Error getting 'rotate' preference: %s", error->message);
- g_error_free (error);
- error = NULL;
+ fish->orientation = panel_applet_get_orient (applet);
- fish->rotate = FALSE; /* Fallback */
- }
+ fish->settings = panel_applet_settings_new (applet, FISH_SCHEMA);
+ fish->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
+
+ g_signal_connect (fish->settings, "changed",
+ G_CALLBACK (fish_applet_settings_changed), fish);
+ /* NULL means we will update for all settings */
+ fish_applet_settings_changed (fish->settings, NULL, fish);
action_group = gtk_action_group_new ("Fish Applet Actions");
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
@@ -1915,19 +1496,11 @@ static void
fish_applet_dispose (GObject *object)
{
FishApplet *fish = (FishApplet *) object;
- int i;
if (fish->timeout)
g_source_remove (fish->timeout);
fish->timeout = 0;
- for (i = 0; i < N_FISH_LISTENERS; i++) {
- if (fish->client && fish->listeners [i] != 0)
- gconf_client_notify_remove (
- fish->client, fish->listeners [i]);
- fish->listeners [i] = 0;
- }
-
if (fish->name)
g_free (fish->name);
fish->name = NULL;
@@ -1940,9 +1513,13 @@ fish_applet_dispose (GObject *object)
g_free (fish->command);
fish->command = NULL;
- if (fish->client)
- g_object_unref (fish->client);
- fish->client = NULL;
+ if (fish->settings)
+ g_object_unref (fish->settings);
+ fish->settings = NULL;
+
+ if (fish->lockdown_settings)
+ g_object_unref (fish->lockdown_settings);
+ fish->lockdown_settings = NULL;
if (fish->surface)
cairo_surface_destroy (fish->surface);
@@ -1973,9 +1550,8 @@ static void
fish_applet_instance_init (FishApplet *fish,
FishAppletClass *klass)
{
- int i;
-
- fish->client = gconf_client_get_default ();
+ fish->settings = NULL;
+ fish->lockdown_settings = NULL;
fish->name = NULL;
fish->image = NULL;
@@ -2004,14 +1580,6 @@ fish_applet_instance_init (FishApplet *fish,
fish->pixbuf = NULL;
fish->preferences_dialog = NULL;
- fish->name_entry = NULL;
- fish->command_label = NULL;
- fish->command_entry = NULL;
- fish->preview_image = NULL;
- fish->image_chooser = NULL;
- fish->frames_spin = NULL;
- fish->speed_spin = NULL;
- fish->rotate_toggle = NULL;
fish->fortune_dialog = NULL;
fish->fortune_view = NULL;
@@ -2022,9 +1590,6 @@ fish_applet_instance_init (FishApplet *fish,
fish->source_id = 0;
fish->io_channel = NULL;
- for (i = 0; i < N_FISH_LISTENERS; i++)
- fish->listeners [i] = 0;
-
fish->april_fools = FALSE;
panel_applet_set_flags (PANEL_APPLET (fish),
diff --git a/applets/fish/fish.ui b/applets/fish/fish.ui
index 2ce4b78..07e6a99 100644
--- a/applets/fish/fish.ui
+++ b/applets/fish/fish.ui
@@ -43,7 +43,7 @@
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
- <property name="label" translatable="no"> </property>
+ <property name="label"> </property>
</object>
<packing>
<property name="expand">False</property>
@@ -57,7 +57,7 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkHBox" id="name_box">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
@@ -91,7 +91,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox3">
+ <object class="GtkHBox" id="command_box">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
@@ -178,27 +178,16 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkImage" id="preview_image">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox2">
+ <object class="GtkHBox" id="speed_box">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkLabel" id="image_label">
+ <object class="GtkLabel" id="speed_label">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="yalign">1</property>
- <property name="ypad">6</property>
- <property name="label" translatable="yes">_File:</property>
+ <property name="label" translatable="yes">_Pause per frame:</property>
<property name="use_underline">True</property>
+ <property name="mnemonic_widget">speed_spin</property>
</object>
<packing>
<property name="expand">False</property>
@@ -207,139 +196,36 @@
</packing>
</child>
<child>
- <object class="GtkFileChooserButton" id="image_chooser">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Select an animation</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox8">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkVBox" id="vbox10">
+ <object class="GtkSpinButton" id="speed_spin">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="frames_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Total frames in animation:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">frames_spin</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="speed_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Pause per frame:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">speed_spin</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="adjustment">adjustment2</property>
+ <property name="climb_rate">0.10000000149</property>
+ <property name="digits">1</property>
+ <property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkTable" id="table2">
+ <object class="GtkLabel" id="speed_post_label">
<property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="frames_post_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">frames</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="speed_post_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">seconds</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="speed_spin">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment2</property>
- <property name="climb_rate">0.10000000149</property>
- <property name="digits">1</property>
- <property name="numeric">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="frames_spin">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
- <property name="climb_rate">1</property>
- <property name="numeric">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">seconds</property>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -427,16 +313,16 @@
</action-widgets>
</object>
<object class="GtkAdjustment" id="adjustment1">
- <property name="value">3</property>
<property name="lower">1</property>
<property name="upper">255</property>
+ <property name="value">3</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
- <property name="value">1</property>
<property name="lower">0.10000000000000001</property>
<property name="upper">10</property>
+ <property name="value">1</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">1</property>
</object>
diff --git a/applets/fish/fishanim.fish b/applets/fish/fishanim.fish
new file mode 100644
index 0000000..0f4a767
--- /dev/null
+++ b/applets/fish/fishanim.fish
@@ -0,0 +1,3 @@
+[Fish Animation]
+image=fishanim.png
+frames=3
diff --git a/applets/fish/footguy.fish b/applets/fish/footguy.fish
new file mode 100644
index 0000000..10fcb36
--- /dev/null
+++ b/applets/fish/footguy.fish
@@ -0,0 +1,3 @@
+[Fish Animation]
+image=footguy.png
+frames=2
diff --git a/applets/fish/monkey.fish b/applets/fish/monkey.fish
new file mode 100644
index 0000000..fbc135b
--- /dev/null
+++ b/applets/fish/monkey.fish
@@ -0,0 +1,3 @@
+[Fish Animation]
+image=monkey.png
+frames=6
diff --git a/applets/fish/oldwanda.fish b/applets/fish/oldwanda.fish
new file mode 100644
index 0000000..6bf3855
--- /dev/null
+++ b/applets/fish/oldwanda.fish
@@ -0,0 +1,3 @@
+[Fish Animation]
+image=oldwanda.png
+frames=3
diff --git a/applets/fish/wanda.fish b/applets/fish/wanda.fish
new file mode 100644
index 0000000..3a88f7d
--- /dev/null
+++ b/applets/fish/wanda.fish
@@ -0,0 +1,3 @@
+[Fish Animation]
+image=wanda.png
+frames=8
diff --git a/data/org.gnome.gnome-panel.applet.fish.gschema.xml b/data/org.gnome.gnome-panel.applet.fish.gschema.xml
index 8335b88..9bae05c 100644
--- a/data/org.gnome.gnome-panel.applet.fish.gschema.xml
+++ b/data/org.gnome.gnome-panel.applet.fish.gschema.xml
@@ -6,7 +6,7 @@
<description>A fish without a name is a pretty dull fish. Bring your fish to life by naming him.</description>
</key>
<key name="image" type="s">
- <default>'wanda.png'</default>
+ <default>'wanda.fish'</default>
<summary>The fish's animation pixmap</summary>
<description>This key specifies the filename of the pixmap which will be used for the animation displayed in the fish applet relative to the pixmap directory.</description>
</key>
@@ -15,13 +15,9 @@
<summary>Command to execute on click</summary>
<description>This key specifies the command that will be tried to execute when the fish is clicked.</description>
</key>
- <key name="frames" type="i">
- <default>8</default>
- <summary>Frames in fish's animation</summary>
- <description>This key specifies the number of frames that will be displayed in the fish's animation.</description>
- </key>
<key name="speed" type="d">
<default>0.3</default>
+ <range min="0.01" max="10.0"/>
<summary>Pause per frame</summary>
<description>This key specifies the number of seconds each frame will be displayed.</description>
</key>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]