# HG changeset patch
# User Darren Salt <[EMAIL PROTECTED]>
# Date 1171841331 0
# Node ID 9c4472b594b70ee7d7ee637ca81298c62c025e7f
# Parent 46307e235fcd7ac468be033854772db42acdbfc9
Add revert buttons (to default & to saved) for each prefs config item.
diff -r 9c4472b594b70ee7d7ee637ca81298c62c025e7f -r
46307e235fcd7ac468be033854772db42acdbfc9 ChangeLog
--- a/ChangeLog Sun Feb 18 23:28:51 2007 +0000
+++ b/ChangeLog Sun Feb 18 17:32:27 2007 +0000
@@ -5,6 +5,8 @@ 0.5.900:2007/??/??
Updated the skip forward/back key bindings accordingly.
* Display some device information in the prefs window and in file
chooser dboxes (requires HAL).
+ * Added revert buttons (to default & to saved) for each config item
+ in the prefs window.
* Added a "repeat track" option to the playlist window.
* Added a system tray icon with two menus - left click for a short
playback control menu, right click for the main menu. Also middle
diff -r 9c4472b594b70ee7d7ee637ca81298c62c025e7f -r
46307e235fcd7ac468be033854772db42acdbfc9 src/preferences.c
--- a/src/preferences.c Sun Feb 18 23:28:51 2007 +0000
+++ b/src/preferences.c Sun Feb 18 17:32:27 2007 +0000
@@ -47,7 +47,7 @@
typedef struct {
void *notebook; /* NULL - get from parent */
- GtkWidget *editable, *label, *separator;
+ GtkWidget *todefault, *revert, *editable, *label, *separator;
int exp;
} pref_item_t;
#define PREF_ITEM_T(NODE) ((pref_item_t *)(NODE)->data)
@@ -116,6 +116,8 @@ static int select_show_prefs_internal (G
}
if (pref->exp <= exp)
last = pref;
+ func (pref->todefault);
+ func (pref->revert);
func (pref->editable);
func (pref->label);
func (pref->separator);
@@ -432,6 +434,116 @@ static void file_map_cb (GtkFileChooser
#ifdef WITH_HAL
file_preview_cb (fcb, fc);
#endif
+}
+
+static void
+default_item_cb (GtkWidget *w, gpointer key)
+{
+ xine_cfg_entry_t entry;
+ xine_config_lookup_entry (xine, key, &entry);
+ if (entry.type == XINE_CONFIG_TYPE_STRING)
+ entry.str_value = entry.str_default;
+ else
+ entry.num_value = entry.num_default;
+ preferences_update_entry (&entry);
+}
+
+static inline GtkWidget *
+create_item_default (const xine_cfg_entry_t * entry)
+{
+ char *tip;
+ gboolean alloc = FALSE;
+
+ switch (entry->type)
+ {
+ case XINE_CONFIG_TYPE_ENUM:
+ tip = entry->enum_values[entry->num_default];
+ break;
+
+ case XINE_CONFIG_TYPE_RANGE:
+ case XINE_CONFIG_TYPE_NUM:
+ alloc = TRUE;
+ tip = g_strdup_printf ("%d", entry->num_default);
+ break;
+
+ case XINE_CONFIG_TYPE_BOOL:
+ tip = entry->num_default ? "✓" : "✗";
+ break;
+
+ case XINE_CONFIG_TYPE_STRING:
+ tip = entry->str_default;
+ break;
+
+ default:
+ return NULL;
+ }
+
+ GtkWidget *widget = ui_button_new_stock (GTK_STOCK_CLEAR);
+ gtk_tooltips_set_tip (tooltips, widget, tip, NULL);
+ if (alloc)
+ free (tip);
+
+ g_signal_connect ((GObject *) widget, "clicked",
+ G_CALLBACK (default_item_cb), (gpointer) entry->key);
+ return widget;
+}
+
+static void
+revert_item_cb (GtkWidget *w, gpointer key)
+{
+ xine_cfg_entry_t entry;
+ xine_config_lookup_entry (xine, key, &entry);
+ if (entry.type == XINE_CONFIG_TYPE_STRING)
+ entry.str_value = g_object_get_data ((GObject *) w, "revert");
+ else
+ entry.num_value = (int) (intptr_t) g_object_get_data ((GObject *) w,
"revert");
+ preferences_update_entry (&entry);
+}
+
+static inline GtkWidget *
+create_item_revert (const xine_cfg_entry_t *entry)
+{
+ intptr_t value;
+ char *tip;
+ gboolean alloc = FALSE;
+
+ switch (entry->type)
+ {
+ case XINE_CONFIG_TYPE_ENUM:
+ tip = entry->enum_values[entry->num_value];
+ value = entry->num_value;
+ break;
+
+ case XINE_CONFIG_TYPE_RANGE:
+ case XINE_CONFIG_TYPE_NUM:
+ alloc = TRUE;
+ tip = g_strdup_printf ("%d", entry->num_value);
+ value = entry->num_value;
+ break;
+
+ case XINE_CONFIG_TYPE_BOOL:
+ tip = entry->num_value ? "✓" : "✗";
+ value = entry->num_value;
+ break;
+
+ case XINE_CONFIG_TYPE_STRING:
+ tip = entry->str_value;
+ value = (intptr_t) strdup (entry->str_value);
+ break;
+
+ default:
+ return NULL;
+ }
+
+ GtkWidget *widget = ui_button_new_stock (GTK_STOCK_REVERT_TO_SAVED);
+ g_object_set_data ((GObject *) widget, "revert", (void *) value);
+ g_signal_connect ((GObject *) widget, "clicked",
+ G_CALLBACK (revert_item_cb), (gpointer) entry->key);
+ gtk_tooltips_set_tip (tooltips, widget, tip, NULL);
+ if (alloc)
+ free (tip);
+
+ return widget;
}
static GtkWidget *create_item_editable (const xine_cfg_entry_t *entry)
@@ -588,6 +700,8 @@ static GNode *create_item (const xine_cf
{
pref_item_t *item = malloc (sizeof (pref_item_t));
item->notebook = NULL;
+ item->todefault = create_item_default (entry);
+ item->revert = create_item_revert (entry);
item->editable = create_item_editable (entry);
item->label = create_item_label (entry);
GtkWidget *extra = create_item_extra (entry);
@@ -760,11 +874,15 @@ static gboolean put_content (GNode *node
/* we have a config item */
int r = g_node_child_position (node->parent, node) * 2;
GtkTable *table = GTK_TABLE(parent->page.table);
+ gtk_table_attach (table, pref->item.todefault, 0, 1, r, r + 1,
+ GTK_FILL, GTK_SHRINK, 2, 5);
+ gtk_table_attach (table, pref->item.revert, 1, 2, r, r + 1,
+ GTK_FILL, GTK_SHRINK, 2, 5);
GtkWidget *extra = g_object_get_data (G_OBJECT (pref->item.editable),
"extra");
if (extra)
{
GtkBox *box = GTK_BOX (gtk_vbox_new (2, FALSE));
- gtk_table_attach (table, (GtkWidget *) box, 0, 1, r, r + 1,
+ gtk_table_attach (table, (GtkWidget *) box, 2, 3, r, r + 1,
GTK_EXPAND | GTK_FILL, GTK_SHRINK, 2, 5);
gtk_box_pack_start_defaults (box, pref->item.editable);
gtk_box_pack_start_defaults (box, extra);
@@ -776,11 +894,11 @@ static gboolean put_content (GNode *node
#endif
}
else
- gtk_table_attach (table, pref->item.editable, 0, 1, r, r + 1,
+ gtk_table_attach (table, pref->item.editable, 2, 3, r, r + 1,
GTK_EXPAND | GTK_FILL, GTK_SHRINK, 2, 5);
- gtk_table_attach (table, pref->item.label, 1, 4, r, r + 1,
+ gtk_table_attach (table, pref->item.label, 3, 6, r, r + 1,
GTK_EXPAND | GTK_FILL, GTK_SHRINK, 5, 5);
- gtk_table_attach (table, pref->item.separator, 0, 4, r + 1, r + 2,
+ gtk_table_attach (table, pref->item.separator, 0, 6, r + 1, r + 2,
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 5, 5);
g_signal_connect (pref->item.editable, "focus",
G_CALLBACK (focus_item_cb), node);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog