diff --git a/ChangeLog b/ChangeLog index 3d69ff9a0..abac23266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-03-19 Richard Hestilow + + * configure.in (COMMON_LIBS): Link to common.la and not common.a. + Sun Mar 17 23:26:02 2002 Jonathan Blandford * capplets/keybindings/eggcellrendererkeys.[ch]: sync to CVS. diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index 32b9179fb..bed779e8c 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,19 @@ +2002-03-19 Richard Hestilow + + * background-properties-capplet.c: + (everywhere): Use an ApplierSet instead of passing around + BGPreferences. + (real_realize_cb): Call applier_set_redraw. + (peditor_value_changed): Merge entry in set->prefs, + and call applier_set_redraw if realized. Also, hide the second + color option if shading type is solid. + (setup_dialog): Set data for the second color selector. + Also, update peditors for new UI. + (create_dialog): Add previews and labels to radio buttons. + (main): Create applier set. Also, connect to DnD signals. + + * background-properties.glade: Implement seth's new UI. + 2002-03-17 Jonathan Blandford reviewed by: diff --git a/capplets/background/background-properties-capplet.c b/capplets/background/background-properties-capplet.c index 4476a47e4..4bae9c59c 100644 --- a/capplets/background/background-properties-capplet.c +++ b/capplets/background/background-properties-capplet.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "capplet-util.h" #include "gconf-property-editor.h" @@ -38,6 +39,75 @@ #include "preview-file-selection.h" #include "activate-settings-daemon.h" +enum +{ + TARGET_URI_LIST +}; + +static GtkTargetEntry drop_types[] = +{ + {"text/uri-list", 0, TARGET_URI_LIST} +}; + +static gint n_drop_types = sizeof (drop_types) / sizeof (GtkTargetEntry); + +static const int n_enum_vals = WPTYPE_NONE + 1; + +typedef struct +{ + BGApplier** appliers; + BGPreferences *prefs; +} ApplierSet; + +/* Create a new set of appliers, and load the default preferences */ + +static ApplierSet* +applier_set_new (void) +{ + int i; + ApplierSet *set = g_new0 (ApplierSet, 1); + + set->appliers = g_new0 (BGApplier*, n_enum_vals); + for (i = 0; i < n_enum_vals; i++) + set->appliers[i] = BG_APPLIER (bg_applier_new (BG_APPLIER_PREVIEW)); + set->prefs = BG_PREFERENCES (bg_preferences_new ()); + bg_preferences_load (set->prefs); + + return set; +} + +/* Destroy all prefs/appliers in set, and free structure */ + +static void +applier_set_free (ApplierSet *set) +{ + int i; + + g_return_if_fail (set != NULL); + + for (i = 0; i < n_enum_vals; i++) + g_object_unref (G_OBJECT (set->appliers[i])); + g_free (set->appliers); + g_object_unref (G_OBJECT (set->prefs)); +} + +/* Trigger a redraw in each applier in the set */ + +static void +applier_set_redraw (ApplierSet *set) +{ + int i; + + g_return_if_fail (set != NULL); + + for (i = 0; i < n_enum_vals; i++) + { + set->prefs->wallpaper_enabled = TRUE; + set->prefs->wallpaper_type = i; + bg_applier_apply_prefs (set->appliers[i], set->prefs); + } +} + /* Retrieve legacy gnome_config settings and store them in the GConf * database. This involves some translation of the settings' meanings. */ @@ -117,6 +187,26 @@ get_legacy_settings (void) gnome_config_pop_prefix (); } +/* Show/hide the secondary color options if needed */ + +static void +update_secondary_color_visibility (ApplierSet *set, const gchar *value_str) +{ + gboolean enable; + GtkWidget *color_frame; + + g_return_if_fail (set != NULL); + g_return_if_fail (value_str != NULL); + + enable = strcmp (value_str, "solid"); + color_frame = g_object_get_data (G_OBJECT (set->prefs), "color2-box"); + if (enable) + gtk_widget_show (color_frame); + else + gtk_widget_hide (color_frame); +} + + /* Initial apply to the preview, and setting of the color frame's sensitivity. * * We use a double-delay mechanism: first waiting 100 ms, then working in an @@ -126,38 +216,35 @@ get_legacy_settings (void) */ static gboolean -real_realize_cb (BGPreferences *prefs) +real_realize_cb (ApplierSet *set) { GtkWidget *color_frame; - BGApplier *bg_applier; - g_return_val_if_fail (prefs != NULL, TRUE); - g_return_val_if_fail (IS_BG_PREFERENCES (prefs), TRUE); + g_return_val_if_fail (set != NULL, TRUE); - if (G_OBJECT (prefs)->ref_count == 0) + if (G_OBJECT (set->prefs)->ref_count == 0) return FALSE; - bg_applier = g_object_get_data (G_OBJECT (prefs), "applier"); - color_frame = g_object_get_data (G_OBJECT (prefs), "color-frame"); - - bg_applier_apply_prefs (bg_applier, prefs); - - gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (bg_applier, prefs)); + color_frame = g_object_get_data (G_OBJECT (set->prefs), "color-frame"); + applier_set_redraw (set); + gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (set->appliers[0], set->prefs)); + return FALSE; } static gboolean -realize_2_cb (BGPreferences *prefs) +realize_2_cb (ApplierSet *set) { - gtk_idle_add ((GtkFunction) real_realize_cb, prefs); + gtk_idle_add ((GtkFunction) real_realize_cb, set); return FALSE; } static void -realize_cb (GtkWidget *widget, BGPreferences *prefs) +realize_cb (GtkWidget *widget, ApplierSet *set) { - gtk_timeout_add (100, (GtkFunction) realize_2_cb, prefs); + gtk_idle_add ((GtkFunction) real_realize_cb, set); + gtk_timeout_add (100, (GtkFunction) realize_2_cb, set); } /* Callback issued when some value changes in a property editor. This merges the @@ -169,35 +256,28 @@ realize_cb (GtkWidget *widget, BGPreferences *prefs) */ static void -peditor_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, BGPreferences *prefs) +peditor_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, ApplierSet *set) { GConfEntry *entry; - BGApplier *bg_applier; GtkWidget *color_frame; entry = gconf_entry_new (key, value); - bg_preferences_merge_entry (prefs, entry); + bg_preferences_merge_entry (set->prefs, entry); gconf_entry_free (entry); - bg_applier = g_object_get_data (G_OBJECT (prefs), "applier"); - - if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (bg_applier))) - bg_applier_apply_prefs (bg_applier, BG_PREFERENCES (prefs)); + if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (set->appliers[n_enum_vals - 1]))) + applier_set_redraw (set); if (!strcmp (key, BG_PREFERENCES_PICTURE_FILENAME) || !strcmp (key, BG_PREFERENCES_PICTURE_OPTIONS)) { - color_frame = g_object_get_data (G_OBJECT (prefs), "color-frame"); - gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (bg_applier, prefs)); + color_frame = g_object_get_data (G_OBJECT (set->prefs), "color-frame"); + gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (set->appliers[0], set->prefs)); + } + else if (!strcmp (key, BG_PREFERENCES_COLOR_SHADING_TYPE)) + { + update_secondary_color_visibility (set, gconf_value_get_string (value)); } -} - -/* Returns the wallpaper enum set before we disabled it */ -static int -get_val_true_cb (GConfPropertyEditor *peditor, gpointer data) -{ - BGPreferences *prefs = (BGPreferences*) data; - return prefs->wallpaper_type; } /* Set up the property editors in the dialog. This also loads the preferences @@ -205,85 +285,97 @@ get_val_true_cb (GConfPropertyEditor *peditor, gpointer data) */ static void -setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, BGApplier *bg_applier) +setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, ApplierSet *set) { - GObject *prefs; GObject *peditor; GConfClient *client; + gchar *color_option; /* Override the enabled setting to make sure background is enabled */ client = gconf_client_get_default (); gconf_client_set_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, TRUE, NULL); - /* Load preferences */ - prefs = bg_preferences_new (); - bg_preferences_load (BG_PREFERENCES (prefs)); - - /* We need to be able to retrieve the applier and the color frame in + /* We need to be able to retrieve the color frame in callbacks */ - g_object_set_data (prefs, "color-frame", WID ("color_frame")); - g_object_set_data (prefs, "applier", bg_applier); + g_object_set_data (G_OBJECT (set->prefs), "color-frame", WID ("color_vbox")); + g_object_set_data (G_OBJECT (set->prefs), "color2-box", WID ("color2_box")); peditor = gconf_peditor_new_select_menu_with_enum - (changeset, BG_PREFERENCES_COLOR_SHADING_TYPE, WID ("color_option"), bg_preferences_orientation_get_type (), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); + (changeset, BG_PREFERENCES_COLOR_SHADING_TYPE, WID ("border_shading"), bg_preferences_orientation_get_type (), NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, set); peditor = gconf_peditor_new_color - (changeset, BG_PREFERENCES_PRIMARY_COLOR, WID ("colorpicker1"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); + (changeset, BG_PREFERENCES_PRIMARY_COLOR, WID ("color1"), NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, set); peditor = gconf_peditor_new_color - (changeset, BG_PREFERENCES_SECONDARY_COLOR, WID ("colorpicker2"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - peditor = gconf_peditor_new_filename - (changeset, BG_PREFERENCES_PICTURE_FILENAME, WID ("image_fileentry"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - peditor = gconf_peditor_new_select_menu_with_enum - (changeset, BG_PREFERENCES_PICTURE_OPTIONS, WID ("image_option"), bg_preferences_wptype_get_type (), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - peditor = gconf_peditor_new_enum_toggle - (changeset, BG_PREFERENCES_PICTURE_OPTIONS, WID ("picture_enabled_check"), bg_preferences_wptype_get_type (), get_val_true_cb, WPTYPE_NONE, prefs, NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("picture_frame")); + (changeset, BG_PREFERENCES_SECONDARY_COLOR, WID ("color2"), NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, set); + peditor = gconf_peditor_new_image + (changeset, BG_PREFERENCES_PICTURE_FILENAME, WID ("background_image_button"), NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, set); + + peditor = gconf_peditor_new_select_radio_with_enum + (changeset, BG_PREFERENCES_PICTURE_OPTIONS, gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("radiobutton1"))), bg_preferences_wptype_get_type (), NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, set); /* Make sure preferences get applied to the preview */ - if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (bg_applier))) - bg_applier_apply_prefs (bg_applier, BG_PREFERENCES (prefs)); + if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (set->appliers[n_enum_vals - 1]))) + applier_set_redraw (set); else - g_signal_connect_after (G_OBJECT (bg_applier_get_preview_widget (bg_applier)), "realize", - (GCallback) realize_cb, prefs); - - preview_file_selection_hookup_file_entry (GNOME_FILE_ENTRY (WID ("image_fileentry")), _("Please select a background image")); - - /* Make sure the preferences object gets destroyed when the dialog is - closed */ - g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, prefs); + g_signal_connect_after (G_OBJECT (bg_applier_get_preview_widget (set->appliers[n_enum_vals - 1])), + "realize", (GCallback) realize_cb, set); + + color_option = gconf_client_get_string (gconf_client_get_default (), + BG_PREFERENCES_COLOR_SHADING_TYPE, + NULL); + update_secondary_color_visibility (set, color_option); + g_free (color_option); } /* Construct the dialog */ static GladeXML * -create_dialog (BGApplier *bg_applier) +create_dialog (ApplierSet *set) { - GtkWidget *holder; GtkWidget *widget; GladeXML *dialog; + GSList *group; + int i; + const gchar *labels[] = { N_("Wallpaper"), N_("Centered"), N_("Scaled"), N_("Stretched"), N_("No Picture") }; /* FIXME: What the hell is domain? */ dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/background-properties.glade", "prefs_widget", NULL); widget = glade_xml_get_widget (dialog, "prefs_widget"); - /* Minor GUI addition */ - holder = WID ("prefs_widget"); - gtk_box_pack_start (GTK_BOX (holder), bg_applier_get_preview_widget (bg_applier), TRUE, TRUE, 0); - gtk_widget_show_all (holder); - g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_object_unref, dialog); + /* Set up the applier buttons */ + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("radiobutton1"))); + group = g_slist_copy (group); + group = g_slist_reverse (group); + + for (i = 0; group && i < n_enum_vals; i++, group = group->next) + { + GtkWidget *w = GTK_WIDGET (group->data); + GtkWidget *vbox = gtk_vbox_new (FALSE, 4); + + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + + gtk_widget_destroy (GTK_BIN (w)->child); + gtk_container_add (GTK_CONTAINER (w), vbox); + + gtk_box_pack_start (GTK_BOX (vbox), + bg_applier_get_preview_widget (set->appliers[i]), + TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), + gtk_label_new (gettext (labels[i])), + FALSE, FALSE, 0); + gtk_widget_show_all (vbox); + } + + g_slist_free (group); + return dialog; } @@ -299,14 +391,75 @@ dialog_button_clicked_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *c } } +/* Callback issued during drag movements */ + +static gboolean +drag_motion_cb (GtkWidget *widget, GdkDragContext *context, + gint x, gint y, guint time, gpointer data) +{ + return FALSE; +} + +/* Callback issued during drag leaves */ + +static void +drag_leave_cb (GtkWidget *widget, GdkDragContext *context, + guint time, gpointer data) +{ + gtk_widget_queue_draw (widget); +} + +/* Callback issued on actual drops. Attempts to load the file dropped. */ + +static void +drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, + gint x, gint y, + GtkSelectionData *selection_data, + guint info, guint time, gpointer data) +{ + GList *list; + GList *uris; + ApplierSet *set = (ApplierSet*) data; + + if (info != TARGET_URI_LIST) + return; + + uris = gnome_vfs_uri_list_parse ((gchar *) selection_data-> + data); + for (list = uris; list; list = list->next) + { + GnomeVFSURI *uri = (GnomeVFSURI *) list->data; + GConfEntry *entry; + GConfValue *value = gconf_value_new (GCONF_VALUE_STRING); + GConfClient *client = gconf_client_get_default (); + + gconf_value_set_string (value, gnome_vfs_uri_get_path (uri)); + + /* Hmm, should we bother with changeset here? */ + gconf_client_set (client, BG_PREFERENCES_PICTURE_FILENAME, value, NULL); + gconf_client_suggest_sync (client, NULL); + + /* this isn't emitted by the peditors, + * so we have to manually update */ + entry = gconf_entry_new (BG_PREFERENCES_PICTURE_FILENAME, value); + bg_preferences_merge_entry (set->prefs, entry); + gconf_entry_free (entry); + gconf_value_free (value); + } + + if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (set->appliers[n_enum_vals - 1]))) + applier_set_redraw (set); + + gnome_vfs_uri_list_free (uris); +} + int main (int argc, char **argv) { GConfClient *client; - GConfChangeSet *changeset; GladeXML *dialog; GtkWidget *dialog_win; - GObject *bg_applier; + ApplierSet *set; static gboolean get_legacy; static struct poptOption cap_options[] = { @@ -331,9 +484,9 @@ main (int argc, char **argv) if (get_legacy) { get_legacy_settings (); } else { - bg_applier = bg_applier_new (BG_APPLIER_PREVIEW); - dialog = create_dialog (BG_APPLIER (bg_applier)); - setup_dialog (dialog, NULL, BG_APPLIER (bg_applier)); + set = applier_set_new (); + dialog = create_dialog (set); + setup_dialog (dialog, NULL, set); dialog_win = gtk_dialog_new_with_buttons (_("Background properties"), NULL, -1, @@ -342,12 +495,22 @@ main (int argc, char **argv) g_signal_connect (G_OBJECT (dialog_win), "response", (GCallback) dialog_button_clicked_cb, NULL); - g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) g_object_unref, bg_applier); + gtk_drag_dest_set (dialog_win, GTK_DEST_DEFAULT_ALL, + drop_types, n_drop_types, + GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE); + g_signal_connect (G_OBJECT (dialog_win), "drag-motion", + G_CALLBACK (drag_motion_cb), NULL); + g_signal_connect (G_OBJECT (dialog_win), "drag-leave", + G_CALLBACK (drag_leave_cb), NULL); + g_signal_connect (G_OBJECT (dialog_win), "drag-data-received", + G_CALLBACK (drag_data_received_cb), + set); + + g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) applier_set_free, set); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL); - gtk_widget_show_all (dialog_win); + gtk_widget_show (dialog_win); gtk_main (); - gconf_change_set_unref (changeset); } return 0; diff --git a/capplets/background/background-properties.glade b/capplets/background/background-properties.glade index 156493dfd..e1bac5e5f 100644 --- a/capplets/background/background-properties.glade +++ b/capplets/background/background-properties.glade @@ -1,382 +1,597 @@ - + - + - - window1 - GTK_WINDOW_TOPLEVEL - no - no - yes - no - GTK_WIN_POS_NONE + + Background Properties + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False - - - 4 - no - 0 - yes + + + True + True + True + True + GTK_POS_TOP + False + 2 + 2 + False - - - 4 - Background picture - 0 - GTK_SHADOW_ETCHED_IN - yes + + + True + False + 0 - - - 10 - no - 10 - 3 - 2 - 2 - yes + + + 10 + True + False + 0 - - - Image: - GTK_JUSTIFY_CENTER - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 0 - 1 - 0 - 0 - fill - - - + + + True + False + 15 - - - Style: - GTK_JUSTIFY_CENTER - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 1 - 2 - 0 - 0 - fill - - - + + + True + Picture: + 0 + GTK_SHADOW_ETCHED_IN - - - 7.45058e-09 - 0.5 - 0 - 1 - yes + + + True + True + GTK_RELIEF_NORMAL - - - yes - 0 - yes + + + True + False + 0 - - - yes + + + True + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + - - - yes + + + True + + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + True + True + + - - - Tiled - 0.0 - convertwidget2 - yes - yes - - - - + + + True + False + 0 - - - yes + + + True + + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + True + False + + - - - Centered - 0.0 - convertwidget3 - yes - yes - - - - + + + True + You can drag image files +into the window to set the +background picture. + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + - - - yes + + + True + + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + True + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + - - - Scaled (keep aspect ratio) - 0.0 - convertwidget4 - yes - yes - - - - + + + 10 + True + False + 0 - - - yes + + + True + Border the picture with a: + False + False + GTK_JUSTIFY_LEFT + False + False + 7.45058e-09 + 0.5 + 3 + 0 + + + 0 + False + False + + - - - Stretched - 0.0 - convertwidget5 - yes - yes - - - - - - - - - - - 1 - 2 - 1 - 2 - 0 - 0 - fill - - - + + + True + False + 0 - - - no - no - yes + + + True + False + 0 - - - yes - yes - - 0 - yes - yes - - - - - 1 - 2 - 0 - 1 - 0 - 0 - expand|fill - - - - - - - - 0 - no - no - GTK_PACK_END - - + + + True + True + -1 - - - 4 - Background colors - 0 - GTK_SHADOW_ETCHED_IN - yes + + + True - - - 10 - no - 8 - yes + + + True + Solid color + + - - - Style: - GTK_JUSTIFY_CENTER - no - 0.5 - 0.5 - 0 - 0 - yes - - - 0 - no - no - - + + + True + Horizontal gradient + + - - - yes - 0 - yes + + + True + Vertical gradient + + + + + + + 0 + False + False + + + + + 0 + False + False + + - - - yes + + + True + False + 10 - - - yes + + + True + + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + True + False + + - - - Solid color - 0.0 - convertwidget11 - yes - yes - - - - + + + True + False + 3 - - - yes + + + True + Primary Color + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - - - Horizontal gradient - 0.0 - convertwidget12 - yes - yes - - - - + + + True + True + True + False + Pick a color + + + 0 + False + False + + + + + 0 + False + True + + - - - yes + + + True + False + 3 - - - Vertical gradient - 0.0 - convertwidget13 - yes - yes - - - - - - - - - 0 - no - no - - + + + True + Secondary Color + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - - - yes - yes - no - Pick a color - yes - - - 0 - no - no - - + + + True + True + True + False + Pick a color + + + 0 + False + False + + + + + 0 + False + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + GTK_PACK_END + + - - - yes - yes - no - Pick a color - yes - - - 0 - no - no - - - - - - - 0 - no - no - GTK_PACK_END - - + + + 10 + True + Picture Options: + 0 + GTK_SHADOW_ETCHED_IN + + + + True + False + 2 + + + + True + True + 5 + + + + True + True + radiobutton1 + True + GTK_RELIEF_NORMAL + False + False + False + + + 0 + False + False + + + + + + True + True + radiobutton2 + True + GTK_RELIEF_NORMAL + False + False + False + radiobutton1 + + + 0 + False + False + + + + + + True + True + radiobutton3 + True + GTK_RELIEF_NORMAL + False + False + False + radiobutton1 + + + 0 + False + False + + + + + + True + True + radiobutton4 + True + GTK_RELIEF_NORMAL + False + False + False + radiobutton1 + + + 0 + False + False + + + + + + True + True + radiobutton5 + True + GTK_RELIEF_NORMAL + False + False + False + radiobutton1 + + + 0 + False + False + + + + + 0 + True + True + + + + + + + 0 + True + True + GTK_PACK_END + + + + + False + True + + + + + + True + E-Mail + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + - - - yes - Use a picture for the background - no - yes - yes - - - 0 - no - no - GTK_PACK_END - - - - - diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index da9deae8c..916894991 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,17 @@ +2002-03-19 Richard Hestilow + + * Makefile.am: Include libbackground (used for preview-file-selector). + Change into a libtool library so we can link against libbackground. + + * gconf-property-editor.c: + (peditor_enum_int_from_string): Added argument use_nick; set to true + if the string was a nick. + (peditor_enum_string_from_int): Use nick only if use_nick is true. + (gconf_peditor_new_image): Added. + (gconf_peditor_new_select_radio_with_enum): Added. + (peditor_select_radio_value_changed): Reverse radio group. + (peditor_select_radio_widget_changed): Reverse radio group. + 2002-03-17 Kjartan Maraas * activate-settings-daemon.c: Mark a string. #include diff --git a/capplets/common/Makefile.am b/capplets/common/Makefile.am index a9454b4e9..eb2a980f0 100644 --- a/capplets/common/Makefile.am +++ b/capplets/common/Makefile.am @@ -5,13 +5,17 @@ INCLUDES = \ -DGNOME_ICONDIR=\""${prefix}/share/pixmaps"\" \ -DG_LOG_DOMAIN=\"capplet-common\" \ -I$(top_srcdir)/ \ + -I$(top_srcdir)/libbackground \ @CAPPLET_CFLAGS@ + -noinst_LIBRARIES = libcommon.a +noinst_LTLIBRARIES = libcommon.la -libcommon_a_SOURCES = \ +libcommon_la_SOURCES = \ activate-settings-daemon.c activate-settings-daemon.h \ capplet-util.c capplet-util.h \ gconf-property-editor.c gconf-property-editor.h \ gconf-property-editor-marshal.c gconf-property-editor-marshal.h \ theme-common.c theme-common.h + +libcommon_la_LIBADD = $(top_builddir)/libbackground/libbackground.la diff --git a/capplets/common/gconf-property-editor.c b/capplets/common/gconf-property-editor.c index 9b97f254f..99544acd1 100644 --- a/capplets/common/gconf-property-editor.c +++ b/capplets/common/gconf-property-editor.c @@ -31,6 +31,8 @@ #include "gconf-property-editor.h" #include "gconf-property-editor-marshal.h" +#include "preview-file-selection.h" + enum { VALUE_CHANGED, LAST_SIGNAL @@ -71,6 +73,7 @@ typedef struct GConfPEditorGetValueFn enum_val_true_fn; gpointer enum_val_true_fn_data; guint enum_val_false; + gboolean use_nick; } GConfPropertyEditorEnumData; static guint peditor_signals[LAST_SIGNAL]; @@ -660,16 +663,23 @@ gconf_peditor_new_color (GConfChangeSet *changeset, } static int -peditor_enum_int_from_string (GType type, const gchar *str) +peditor_enum_int_from_string (GType type, const gchar *str, gboolean *use_nick) { GEnumClass *klass; GEnumValue *val; int ret = -1; + if (use_nick) + *use_nick = FALSE; + klass = g_type_class_ref (type); val = g_enum_get_value_by_name (klass, str); if (!val) + { val = g_enum_get_value_by_nick (klass, str); + if (use_nick) + *use_nick = TRUE; + } if (val) ret = val->value; @@ -679,7 +689,7 @@ peditor_enum_int_from_string (GType type, const gchar *str) } static gchar* -peditor_enum_string_from_int (GType type, const int index) +peditor_enum_string_from_int (GType type, const int index, gboolean use_nick) { GEnumClass *klass; GEnumValue *val; @@ -689,10 +699,10 @@ peditor_enum_string_from_int (GType type, const int index) val = g_enum_get_value (klass, index); if (val) { - if (val->value_name) - ret = g_strdup (val->value_name); - else + if (val->value_nick && use_nick) ret = g_strdup (val->value_nick); + else + ret = g_strdup (val->value_name); } g_type_class_unref (klass); @@ -714,7 +724,8 @@ peditor_enum_conv_to_widget (GConfPropertyEditor *peditor, ret = gconf_value_new (GCONF_VALUE_INT); index = peditor_enum_int_from_string (data->enum_type, - gconf_value_get_string (value)); + gconf_value_get_string (value), + &data->use_nick); gconf_value_set_int (ret, index); @@ -734,7 +745,8 @@ peditor_enum_conv_from_widget (GConfPropertyEditor *peditor, ret = gconf_value_new (GCONF_VALUE_STRING); str = peditor_enum_string_from_int (data->enum_type, - gconf_value_get_int (value)); + gconf_value_get_int (value), + data->use_nick); gconf_value_set_string (ret, str); g_free (str); @@ -864,7 +876,7 @@ peditor_select_radio_value_changed (GConfClient *client, GConfEntry *entry, GConfPropertyEditor *peditor) { - GSList *group; + GSList *group, *link; GConfValue *value, *value_wid; if (peditor->p->changeset != NULL) @@ -874,11 +886,13 @@ peditor_select_radio_value_changed (GConfClient *client, if (value != NULL) { value_wid = peditor->p->conv_to_widget_cb (peditor, value); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control)); - group = g_slist_nth (group, gconf_value_get_int (value_wid)); - if (group && group->data) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE); + group = g_slist_copy (gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control))); + group = g_slist_reverse (group); + link = g_slist_nth (group, gconf_value_get_int (value_wid)); + if (link && link->data) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (link->data), TRUE); gconf_value_free (value_wid); + g_slist_free (group); } } @@ -893,7 +907,9 @@ peditor_select_radio_widget_changed (GConfPropertyEditor *peditor, if (!tb->active) return; value_wid = gconf_value_new (GCONF_VALUE_INT); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control)); + group = g_slist_copy (gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control))); + group = g_slist_reverse (group); + gconf_value_set_int (value_wid, g_slist_index (group, tb)); value = peditor->p->conv_from_widget_cb (peditor, value_wid); @@ -902,6 +918,7 @@ peditor_select_radio_widget_changed (GConfPropertyEditor *peditor, gconf_value_free (value_wid); gconf_value_free (value); + g_slist_free (group); } GObject * @@ -1021,7 +1038,7 @@ guard_get_bool (GConfPropertyEditor *peditor, const GConfValue *value) else { GConfPropertyEditorEnumData *data = peditor->p->data; - int index = peditor_enum_int_from_string (data->enum_type, gconf_value_get_string (value)); + int index = peditor_enum_int_from_string (data->enum_type, gconf_value_get_string (value), &data->use_nick); return (index != data->enum_val_false); } } @@ -1187,7 +1204,8 @@ peditor_enum_toggle_conv_to_widget (GConfPropertyEditor *peditor, ret = gconf_value_new (GCONF_VALUE_BOOL); index = peditor_enum_int_from_string (data->enum_type, - gconf_value_get_string (value)); + gconf_value_get_string (value), + &data->use_nick); gconf_value_set_bool (ret, (index != data->enum_val_false)); return ret; @@ -1211,7 +1229,7 @@ peditor_enum_toggle_conv_from_widget (GConfPropertyEditor *peditor, else index = data->enum_val_false; - str = peditor_enum_string_from_int (data->enum_type, index); + str = peditor_enum_string_from_int (data->enum_type, index, data->use_nick); gconf_value_set_string (ret, str); g_free (str); @@ -1271,3 +1289,259 @@ gconf_peditor_new_enum_toggle (GConfChangeSet *changeset, return G_OBJECT (peditor); } +gboolean +peditor_image_set_filename (GConfPropertyEditor *peditor, const gchar *filename) +{ + GdkPixbuf *pixbuf = NULL; + GdkPixbuf *scaled; + GtkImage *image = NULL; + const int scale = 100; + gchar *message = NULL; + GList *l; + + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) + { + message = g_strdup_printf (_("Couldn't find the file '%s'.\n\nPlease make " + "sure it exists and try again, " + "or choose a different background picture."), + filename); + + } + else if (!(pixbuf = gdk_pixbuf_new_from_file (filename, NULL))) + { + message = g_strdup_printf (_("I don't know how to open the file '%s'.\n" + "Perhaps it's " + "a kind of picture that is not yet supported.\n\n" + "Please select a different picture instead."), + filename); + } + + if (message) + { + GtkWidget *box; + + box = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + message); + gtk_dialog_run (GTK_DIALOG (box)); + gtk_widget_destroy (box); + g_free (message); + + return FALSE; + } + + scaled = preview_file_selection_intelligent_scale (pixbuf, + scale); + + if (GTK_IS_IMAGE (GTK_BIN (peditor->p->ui_control)->child)) + image = GTK_IMAGE (GTK_BIN (peditor->p->ui_control)->child); + else + { + for (l = gtk_container_get_children (GTK_CONTAINER (GTK_BIN (peditor->p->ui_control)->child)); l != NULL; l = l->next) + { + if (GTK_IS_IMAGE (l->data)) + image = GTK_IMAGE (l->data); + else if (GTK_IS_LABEL (l->data)) + { + gchar *base = g_path_get_basename (filename); + gtk_label_set_text (GTK_LABEL (l->data), base); + g_free (base); + } + } + } + gtk_image_set_from_pixbuf (image, scaled); + g_object_unref (G_OBJECT (pixbuf)); + g_object_unref (G_OBJECT (scaled)); + + return TRUE; +} + +void +peditor_image_fsel_ok_cb (GtkFileSelection *fsel, gpointer data) +{ + GConfValue *value, *value_wid; + GConfPropertyEditor *peditor; + const gchar *filename; + + peditor = g_object_get_data (G_OBJECT (fsel), "peditor"); + + if (!peditor->p->inited) + return; + + filename = gtk_file_selection_get_filename (fsel); + if (!(filename && peditor_image_set_filename (peditor, filename))) + return; + + value_wid = gconf_value_new (GCONF_VALUE_STRING); + gconf_value_set_string (value_wid, gtk_file_selection_get_filename (fsel)); + value = peditor->p->conv_from_widget_cb (peditor, value_wid); + + peditor_set_gconf_value (peditor, peditor->p->key, value); + g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value); + + gconf_value_free (value_wid); + gconf_value_free (value); + gtk_widget_destroy (GTK_WIDGET (fsel)); +} + +void +peditor_image_clicked_cb (GConfPropertyEditor *peditor, GtkButton *button) +{ + GConfValue *value = NULL, *value_wid; + const gchar *filename; + GtkWidget *fsel; + + fsel = preview_file_selection_new (_("Please select an image."), TRUE); + + /* need the current filename */ + if (peditor->p->changeset) + gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value); + + if (value) + { + /* the one we got is not a copy */ + value = gconf_value_copy (value); + } + else + { + GConfClient *client = gconf_client_get_default (); + value = gconf_client_get (client, peditor->p->key, NULL); + } + + value_wid = peditor->p->conv_to_widget_cb (peditor, value); + filename = gconf_value_get_string (value_wid); + + if (filename && strcmp (filename, "")) + gtk_file_selection_set_filename (GTK_FILE_SELECTION (fsel), filename); + + g_object_set_data (G_OBJECT (fsel), "peditor", peditor); + + g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (fsel)->ok_button), + "clicked", + (GCallback) peditor_image_fsel_ok_cb, + fsel); + + g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (fsel)->cancel_button), + "clicked", + (GCallback) gtk_widget_destroy, + fsel); + + if (gtk_grab_get_current ()) + gtk_grab_add (fsel); + + gtk_widget_show (fsel); + + gconf_value_free (value); + gconf_value_free (value_wid); +} + +static void +peditor_image_value_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + GConfPropertyEditor *peditor) +{ + GConfValue *value, *value_wid; + + if (peditor->p->changeset != NULL) + gconf_change_set_remove (peditor->p->changeset, peditor->p->key); + + value = gconf_entry_get_value (entry); + + if (value != NULL) { + const gchar *filename; + + value_wid = peditor->p->conv_to_widget_cb (peditor, value); + filename = gconf_value_get_string (value_wid); + peditor_image_set_filename (peditor, filename); + gconf_value_free (value_wid); + } +} + +GObject * +gconf_peditor_new_image (GConfChangeSet *changeset, + gchar *key, + GtkWidget *button, + gchar *first_property_name, + ...) +{ + GObject *peditor; + va_list var_args; + + g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (button != NULL, NULL); + g_return_val_if_fail (GTK_IS_BUTTON (button), NULL); + + va_start (var_args, first_property_name); + + peditor = gconf_peditor_new + (key, + (GConfClientNotifyFunc) peditor_image_value_changed, + changeset, + G_OBJECT (button), + first_property_name, + var_args, NULL); + + va_end (var_args); + + g_signal_connect_swapped (G_OBJECT (button), "clicked", + (GCallback) peditor_image_clicked_cb, peditor); + + return peditor; +} + +GObject * +gconf_peditor_new_select_radio_with_enum (GConfChangeSet *changeset, + gchar *key, + GSList *radio_group, + GType enum_type, + gchar *first_property_name, + ...) +{ + GConfPropertyEditor *peditor; + GConfPropertyEditorEnumData *enum_data; + GtkRadioButton *first_button; + GSList *item; + va_list var_args; + + g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (radio_group != NULL, NULL); + g_return_val_if_fail (radio_group->data != NULL, NULL); + g_return_val_if_fail (GTK_IS_RADIO_BUTTON (radio_group->data), NULL); + + enum_data = g_new0 (GConfPropertyEditorEnumData, 1); + enum_data->enum_type = enum_type; + + first_button = GTK_RADIO_BUTTON (radio_group->data); + + va_start (var_args, first_property_name); + + peditor = GCONF_PROPERTY_EDITOR ( + gconf_peditor_new + (key, + (GConfClientNotifyFunc) peditor_select_radio_value_changed, + changeset, + G_OBJECT (first_button), + first_property_name, + var_args, + "conv-to-widget-cb", + peditor_enum_conv_to_widget, + "conv-from-widget-cb", + peditor_enum_conv_from_widget, + "data", + enum_data, + "data-free-cb", + g_free, + NULL)); + + va_end (var_args); + + for (item = radio_group; item != NULL; item = item->next) + g_signal_connect_swapped (G_OBJECT (item->data), "toggled", + (GCallback) peditor_select_radio_widget_changed, peditor); + + return G_OBJECT (peditor); +} + diff --git a/capplets/common/gconf-property-editor.h b/capplets/common/gconf-property-editor.h index 23e7f9ed1..da11c7a61 100644 --- a/capplets/common/gconf-property-editor.h +++ b/capplets/common/gconf-property-editor.h @@ -110,6 +110,14 @@ GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset, GSList *radio_group, gchar *first_property_name, ...); + +GObject *gconf_peditor_new_select_radio_with_enum (GConfChangeSet *changeset, + gchar *key, + GSList *radio_group, + GType enum_type, + gchar *first_property_name, + ...); + GObject *gconf_peditor_new_numeric_range (GConfChangeSet *changeset, gchar *key, GtkWidget *range, @@ -121,6 +129,12 @@ GObject *gconf_peditor_new_font (GConfChangeSet *changeset, gchar *first_property_name, ...); +GObject *gconf_peditor_new_image (GConfChangeSet *changeset, + gchar *key, + GtkWidget *button, + gchar *first_property, + ...); + void gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor, GtkWidget *widget); diff --git a/capplets/keyboard/ChangeLog b/capplets/keyboard/ChangeLog index 30f88eeed..a4ef1bfac 100644 --- a/capplets/keyboard/ChangeLog +++ b/capplets/keyboard/ChangeLog @@ -1,3 +1,12 @@ +2002-03-19 Richard Hestilow + + * gnome-keyboard-properties.c (bell_enums): Swap around. This + was initially reversed because of a bug in gconf-peditor. + Ideally this code should use the new enum functions, but + the existing stuff works so I so no immediate need to rewrite + it. + (*_to/from_widget): Convert to new signature. + 2002-03-19 Lauris Kaplinski * gnome-keyboard-properties.c (bell_to_widget): Check that diff --git a/capplets/keyboard/gnome-keyboard-properties.c b/capplets/keyboard/gnome-keyboard-properties.c index 90f09e218..b1285ef63 100644 --- a/capplets/keyboard/gnome-keyboard-properties.c +++ b/capplets/keyboard/gnome-keyboard-properties.c @@ -53,7 +53,7 @@ create_dialog (void) } static GConfValue * -rate_to_widget (GConfValue *value) +rate_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; int rate; @@ -75,7 +75,7 @@ rate_to_widget (GConfValue *value) } static GConfValue * -rate_from_widget (GConfValue *value) +rate_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { static int rates[] = { 255, 192, 64, 1 @@ -90,7 +90,7 @@ rate_from_widget (GConfValue *value) } static GConfValue * -delay_to_widget (GConfValue *value) +delay_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; int delay; @@ -112,7 +112,7 @@ delay_to_widget (GConfValue *value) } static GConfValue * -delay_from_widget (GConfValue *value) +delay_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { static int delays[] = { 1000, 700, 300, 0 @@ -126,13 +126,13 @@ delay_from_widget (GConfValue *value) } static GConfEnumStringPair bell_enums[] = { - { 0, "custom" }, + { 0, "off" }, { 1, "on" }, - { 2, "off" } + { 2, "custom" } }; static GConfValue * -bell_from_widget (GConfValue *value) +bell_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; @@ -144,7 +144,7 @@ bell_from_widget (GConfValue *value) } static GConfValue * -bell_to_widget (GConfValue *value) +bell_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; gint val = 2; @@ -162,7 +162,7 @@ bell_to_widget (GConfValue *value) static GConfValue * -blink_from_widget (GConfValue *value) +blink_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; @@ -173,7 +173,7 @@ blink_from_widget (GConfValue *value) } static GConfValue * -blink_to_widget (GConfValue *value) +blink_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; gint current_rate; diff --git a/capplets/ui-properties/ChangeLog b/capplets/ui-properties/ChangeLog index ed209bf6f..a6c325bcd 100644 --- a/capplets/ui-properties/ChangeLog +++ b/capplets/ui-properties/ChangeLog @@ -1,3 +1,7 @@ +2002-03-19 Richard Hestilow + + * gnome-ui-properties.c (*_to/from_widget): Convert to new signature. + 2002-02-27 Kjartan Maraas * main.c: s/PACKAGE/GETTEXT_PACKAGE/g diff --git a/capplets/ui-properties/gnome-ui-properties.c b/capplets/ui-properties/gnome-ui-properties.c index b9d2120a1..d122349c5 100644 --- a/capplets/ui-properties/gnome-ui-properties.c +++ b/capplets/ui-properties/gnome-ui-properties.c @@ -43,7 +43,7 @@ static GConfEnumStringPair toolbar_style_enums[] = { }; static GConfValue * -toolbar_from_widget (GConfValue *value) +toolbar_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; @@ -55,7 +55,7 @@ toolbar_from_widget (GConfValue *value) } static GConfValue * -toolbar_to_widget (GConfValue *value) +toolbar_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; gint val = 2; diff --git a/configure.in b/configure.in index e0adee410..39478fa7f 100644 --- a/configure.in +++ b/configure.in @@ -92,7 +92,7 @@ dnl ============================================== dnl Define the main variables dnl ============================================== COMMON_CFLAGS="-I\$(top_srcdir)/capplets/common" -COMMON_LIBS="\$(top_builddir)/capplets/common/libcommon.a" +COMMON_LIBS="\$(top_builddir)/capplets/common/libcommon.la" EXTRA_CFLAGS="-I\$(top_srcdir)/ -DG_LOG_DOMAIN=\"\\\"\$(cappletname)-properties\\\"\" -DGNOMELOCALEDIR=\"\\\"${datadir}/locale\\\"\"" diff --git a/libbackground/ChangeLog b/libbackground/ChangeLog index 1c6fe504e..d1516cfde 100644 --- a/libbackground/ChangeLog +++ b/libbackground/ChangeLog @@ -1,3 +1,23 @@ +2002-03-19 Richard Hestilow + + * preferences.h (wallpaper_type_t): Remove EMBOSSED since we + don't support it. + + * preferences.c: + (_bg_wptype_values, _bg_orientation_values): Move name values + to nick, change name to "correct" form. + (read_wptype_from_string, bg_preferences_get_wptype_as_string): + Remove EMBOSSSED option. + + * preview-file-selection.[ch]: Add function + preview_file_selection_intelligent_scale. + + * applier.c: Change MONITOR_CONTENTS_WIDTH/HEIGHT to 64/48 + (correct monitor ratio). + (bg_applier_apply_prefs): Disable wallpaper if WPTYPE_NONE. + (bg_applier_get_preview_widget): Create to WIDTH/HEIGHT. + (get_geometry): Remove reference to EMBOSSED. + 2002-03-17 Darin Adler * preferences.c: (bg_preferences_merge_entry): diff --git a/libbackground/applier.c b/libbackground/applier.c index 8d514910b..59e65d2c4 100644 --- a/libbackground/applier.c +++ b/libbackground/applier.c @@ -38,10 +38,10 @@ #include "applier.h" -#define MONITOR_CONTENTS_X 20 -#define MONITOR_CONTENTS_Y 10 -#define MONITOR_CONTENTS_WIDTH 157 -#define MONITOR_CONTENTS_HEIGHT 111 +#define MONITOR_CONTENTS_X 0 +#define MONITOR_CONTENTS_Y 0 +#define MONITOR_CONTENTS_WIDTH 64 +#define MONITOR_CONTENTS_HEIGHT 48 enum { PROP_0, @@ -370,6 +370,12 @@ bg_applier_apply_prefs (BGApplier *bg_applier, new_prefs = BG_PREFERENCES (bg_preferences_clone (prefs)); + if (new_prefs->wallpaper_type == WPTYPE_NONE) + { + new_prefs->wallpaper_enabled = FALSE; + new_prefs->wallpaper_type = WPTYPE_CENTERED; + } + if (bg_applier->p->type == BG_APPLIER_ROOT && bg_applier->p->nautilus_running) set_root_pixmap ((GdkPixmap *) -1); @@ -432,65 +438,13 @@ bg_applier_render_color_p (const BGApplier *bg_applier, const BGPreferences *pre GtkWidget * bg_applier_get_preview_widget (BGApplier *bg_applier) { - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *mask; - GdkVisual *visual; - GdkColormap *colormap; - gchar *filename; - GdkGC *gc; - - g_return_val_if_fail (bg_applier != NULL, NULL); - g_return_val_if_fail (IS_BG_APPLIER (bg_applier), NULL); - - if (bg_applier->p->type != BG_APPLIER_PREVIEW) - return NULL; - - if (bg_applier->p->preview_widget != NULL) - return bg_applier->p->preview_widget; - - filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, "monitor.png", TRUE, NULL); - visual = gdk_drawable_get_visual (gdk_get_default_root_window ()); - colormap = gdk_drawable_get_colormap (gdk_get_default_root_window ()); - - gtk_widget_push_colormap (colormap); - - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - - if (pixbuf == NULL) return NULL; - - pixmap = gdk_pixmap_new (gdk_get_default_root_window (), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - visual->depth); - mask = gdk_pixmap_new (gdk_get_default_root_window (), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - 1); - - gc = gdk_gc_new (gdk_get_default_root_window ()); - - gdk_pixbuf_render_threshold_alpha (pixbuf, mask, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - 1); - - gdk_gc_set_clip_mask (gc, mask); - - gdk_pixbuf_render_to_drawable (pixbuf, pixmap, gc, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_MAX, 0, 0); - - bg_applier->p->preview_widget = gtk_image_new_from_pixmap (pixmap, mask); - gtk_widget_show (bg_applier->p->preview_widget); - g_object_unref (G_OBJECT (pixbuf)); - g_free (filename); - - gtk_widget_pop_colormap (); + if (bg_applier->p->preview_widget == NULL) + { + GdkPixmap *pixmap; + pixmap = gdk_pixmap_new (gdk_get_default_root_window (), MONITOR_CONTENTS_WIDTH, MONITOR_CONTENTS_HEIGHT, -1); + bg_applier->p->preview_widget = gtk_image_new_from_pixmap (pixmap, NULL); + } return bg_applier->p->preview_widget; } diff --git a/libbackground/preferences.c b/libbackground/preferences.c index 2e697afeb..0fdf7b3bf 100644 --- a/libbackground/preferences.c +++ b/libbackground/preferences.c @@ -45,19 +45,18 @@ static orientation_t read_orientation_from_string (gchar *string); static wallpaper_type_t read_wptype_from_string (gchar *string); static GEnumValue _bg_wptype_values[] = { - { WPTYPE_TILED, "wallpaper", N_("Tiled") }, - { WPTYPE_CENTERED, "centered", N_("Centered") }, - { WPTYPE_SCALED, "scaled", N_("Scaled") }, - { WPTYPE_STRETCHED, "stretched", N_("Stretched") }, - { WPTYPE_EMBOSSED, "embossed", N_("Embossed") }, - { WPTYPE_NONE, "none", N_("None") }, + { WPTYPE_TILED, "WPTYPE_TILED", "wallpaper"}, + { WPTYPE_CENTERED, "WPTYPE_CENTERED", "centered"}, + { WPTYPE_SCALED, "WPTYPE_SCALED", "scaled"}, + { WPTYPE_STRETCHED, "WPTYPE_STRETCHED", "stretched"}, + { WPTYPE_NONE, "WPTYPE_NONE", "none"}, { 0, NULL, NULL } }; static GEnumValue _bg_orientation_values[] = { - { ORIENTATION_SOLID, "solid", N_("Solid") }, - { ORIENTATION_HORIZ, "horizontal-gradient", N_("Horizontal Gradient") }, - { ORIENTATION_VERT, "vertical-gradient", N_("Vertical Gradient") }, + { ORIENTATION_SOLID, "ORIENTATION_SOLID", "solid"}, + { ORIENTATION_HORIZ, "ORIENTATION_HORIZ", "horizontal-gradient"}, + { ORIENTATION_VERT, "ORIENTATION_VERT", "vertical-gradient"}, { 0, NULL, NULL } }; @@ -326,8 +325,6 @@ read_wptype_from_string (gchar *string) type = WPTYPE_SCALED; } else if (!strncmp (string, "stretched", sizeof ("stretched"))) { type = WPTYPE_STRETCHED; - } else if (!strncmp (string, "embossed", sizeof ("embossed"))) { - type = WPTYPE_EMBOSSED; } g_free (string); } @@ -384,8 +381,6 @@ bg_preferences_get_wptype_as_string (wallpaper_type_t wp) return "scaled"; case WPTYPE_STRETCHED: return "stretched"; - case WPTYPE_EMBOSSED: - return "embossed"; case WPTYPE_NONE: return "none"; case WPTYPE_UNSET: diff --git a/libbackground/preferences.h b/libbackground/preferences.h index 14a3c5621..ad2d719eb 100644 --- a/libbackground/preferences.h +++ b/libbackground/preferences.h @@ -52,7 +52,7 @@ typedef enum _orientation_t { typedef enum _wallpaper_type_t { WPTYPE_TILED = 0, WPTYPE_CENTERED, WPTYPE_SCALED, - WPTYPE_STRETCHED, WPTYPE_EMBOSSED, WPTYPE_NONE, + WPTYPE_STRETCHED, WPTYPE_NONE, WPTYPE_UNSET } wallpaper_type_t; diff --git a/libbackground/preview-file-selection.c b/libbackground/preview-file-selection.c index 638f8ce40..c6661c61f 100644 --- a/libbackground/preview-file-selection.c +++ b/libbackground/preview-file-selection.c @@ -127,6 +127,35 @@ preview_file_selection_new (const gchar *title, gboolean do_preview) NULL)); } +GdkPixbuf* +preview_file_selection_intelligent_scale (GdkPixbuf *buf, guint scale) +{ + GdkPixbuf *scaled; + int w, h; + int ow = gdk_pixbuf_get_width (buf); + int oh = gdk_pixbuf_get_height (buf); + + if (ow <= scale && oh <= scale) + scaled = gdk_pixbuf_ref (buf); + else + { + if (ow > oh) + { + w = scale; + h = scale * (((double)oh)/(double)ow); + } + else + { + h = scale; + w = scale * (((double)ow)/(double)ow); + } + + scaled = gdk_pixbuf_scale_simple (buf, w, h, GDK_INTERP_BILINEAR); + } + + return scaled; +} + static void preview_file_selection_update (PreviewFileSelection *fsel, gpointer data) { @@ -138,29 +167,7 @@ preview_file_selection_update (PreviewFileSelection *fsel, gpointer data) filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fsel)); if (filename && (buf = gdk_pixbuf_new_from_file (filename, NULL))) { - GdkPixbuf *scaled; - int w, h; - int ow = gdk_pixbuf_get_width (buf); - int oh = gdk_pixbuf_get_height (buf); - - if (ow <= SCALE && oh <= SCALE) - scaled = gdk_pixbuf_ref (buf); - else - { - if (ow > oh) - { - w = SCALE; - h = SCALE * (((double)oh)/(double)ow); - } - else - { - h = SCALE; - w = SCALE * (((double)ow)/(double)ow); - } - - scaled = gdk_pixbuf_scale_simple (buf, w, h, GDK_INTERP_BILINEAR); - } - + GdkPixbuf *scaled = preview_file_selection_intelligent_scale (buf, SCALE); gtk_image_set_from_pixbuf (GTK_IMAGE (fsel->priv->preview), scaled); g_object_unref (scaled); diff --git a/libbackground/preview-file-selection.h b/libbackground/preview-file-selection.h index 64c31dfa2..c81b20b44 100644 --- a/libbackground/preview-file-selection.h +++ b/libbackground/preview-file-selection.h @@ -56,6 +56,8 @@ GtkWidget *preview_file_selection_new (const gchar *title, gboolean do_preview); void preview_file_selection_hookup_file_entry (GnomeFileEntry *entry, const gchar *title); +GdkPixbuf* preview_file_selection_intelligent_scale (GdkPixbuf *pixbuf, guint scale); + G_END_DECLS #endif /* __PREVIEW_FILE_SELECTION_H__ */ diff --git a/po/ChangeLog b/po/ChangeLog index 29d8cef69..ddcd53d38 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2002-03-19 Richard Hestilow + + * POTFILES.in: Add activate-settings-daemon.c. + 2002-03-19 Ole Laursen * da.po: Updated Danish translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index 4bf164f3f..85cc4cb75 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,6 +4,7 @@ capplets/background/background-properties-capplet.c capplets/background/background-properties.glade capplets/common/capplet-util.c capplets/common/gconf-property-editor.c +capplets/common/activate-settings-daemon.c capplets/default-applications/default-applications.desktop.in capplets/default-applications/gnome-default-applications-properties.c capplets/default-applications/gnome-default-applications-properties.glade