Add stash_group_add_combo_box_entry(), stash_group_add_entry().
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3419 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
6a2f565931
commit
c56f0c450b
@ -7,6 +7,8 @@
|
|||||||
Remove remaining PrefEntry code, use Stash instead.
|
Remove remaining PrefEntry code, use Stash instead.
|
||||||
Add stash_group_add_spin_button_integer(),
|
Add stash_group_add_spin_button_integer(),
|
||||||
stash_group_add_combo_box().
|
stash_group_add_combo_box().
|
||||||
|
* src/prefs.c, src/stash.c, src/stash.h, src/keyfile.c:
|
||||||
|
Add stash_group_add_combo_box_entry(), stash_group_add_entry().
|
||||||
|
|
||||||
|
|
||||||
2008-12-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
2008-12-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
@ -113,8 +113,8 @@ static void init_pref_groups(void)
|
|||||||
|
|
||||||
group = stash_group_new(PACKAGE);
|
group = stash_group_new(PACKAGE);
|
||||||
configuration_add_pref_group(group, TRUE);
|
configuration_add_pref_group(group, TRUE);
|
||||||
stash_group_add_string(group, &prefs.default_open_path,
|
stash_group_add_entry(group, &prefs.default_open_path,
|
||||||
"default_open_path", "");
|
"default_open_path", "", "startup_path_entry");
|
||||||
|
|
||||||
stash_group_add_toggle_button(group, &file_prefs.cmdline_new_files,
|
stash_group_add_toggle_button(group, &file_prefs.cmdline_new_files,
|
||||||
"cmdline_new_files", TRUE, "check_cmdline_new_files");
|
"cmdline_new_files", TRUE, "check_cmdline_new_files");
|
||||||
|
@ -240,9 +240,6 @@ void prefs_init_dialog(void)
|
|||||||
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction");
|
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction");
|
||||||
gtk_entry_set_text(GTK_ENTRY(widget), tool_prefs.context_action_cmd);
|
gtk_entry_set_text(GTK_ENTRY(widget), tool_prefs.context_action_cmd);
|
||||||
|
|
||||||
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "startup_path_entry");
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(widget), prefs.default_open_path);
|
|
||||||
|
|
||||||
project_setup_prefs(); /* project files path */
|
project_setup_prefs(); /* project files path */
|
||||||
|
|
||||||
|
|
||||||
@ -659,10 +656,6 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
|
|||||||
g_free(tool_prefs.context_action_cmd);
|
g_free(tool_prefs.context_action_cmd);
|
||||||
tool_prefs.context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
|
tool_prefs.context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
|
||||||
|
|
||||||
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "startup_path_entry");
|
|
||||||
g_free(prefs.default_open_path);
|
|
||||||
prefs.default_open_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
|
|
||||||
|
|
||||||
project_apply_prefs(); /* project file path */
|
project_apply_prefs(); /* project file path */
|
||||||
|
|
||||||
|
|
||||||
|
68
src/stash.c
68
src/stash.c
@ -25,19 +25,21 @@
|
|||||||
/* Mini-library for reading/writing GKeyFile settings and synchronizing widgets with
|
/* Mini-library for reading/writing GKeyFile settings and synchronizing widgets with
|
||||||
* C variables. */
|
* C variables. */
|
||||||
|
|
||||||
/* Memory Usage
|
/* Terms
|
||||||
* Stash will not duplicate strings if they are normally static arrays, such as
|
* 'Setting' is used only for data stored on disk or in memory.
|
||||||
* keyfile group names and key names.
|
* 'Pref' can also include visual widget information.
|
||||||
*
|
*
|
||||||
* Terms
|
* Memory Usage
|
||||||
* 'Setting' is used for data stored on disk or in memory.
|
* Stash will not duplicate strings if they are normally static arrays, such as
|
||||||
* 'Pref' is used mainly for visual widget information. */
|
* keyfile group names and key names, string default values or widget_id names.
|
||||||
|
* String settings and other dynamically allocated settings must be initialized to NULL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "stash.h"
|
#include "stash.h"
|
||||||
#include "utils.h" /* utils_get_setting_*() */
|
#include "utils.h" /* only for utils_get_setting_*(). Stash should not depend on Geany. */
|
||||||
|
|
||||||
#define foreach_array(type, item, array) \
|
#define foreach_array(type, item, array) \
|
||||||
foreach_c_array(item, ((type*)(gpointer)array->data), array->len)
|
foreach_c_array(item, ((type*)(gpointer)array->data), array->len)
|
||||||
@ -236,7 +238,9 @@ void stash_group_add_integer(GeanyPrefGroup *group, gint *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @param default_value Not duplicated. */
|
/* The contents of @a setting will be freed before being replaced, so make sure it is
|
||||||
|
* initialized to @c NULL.
|
||||||
|
* @param default_value Not duplicated. */
|
||||||
void stash_group_add_string(GeanyPrefGroup *group, gchar **setting,
|
void stash_group_add_string(GeanyPrefGroup *group, gchar **setting,
|
||||||
const gchar *key_name, const gchar *default_value)
|
const gchar *key_name, const gchar *default_value)
|
||||||
{
|
{
|
||||||
@ -297,6 +301,32 @@ static void handle_combo_box(GtkWidget *widget, GeanyPrefEntry *entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void handle_entry(GtkWidget *widget, GeanyPrefEntry *entry,
|
||||||
|
PrefAction action)
|
||||||
|
{
|
||||||
|
gchararray *setting = entry->setting;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case PREF_DISPLAY:
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(widget), *setting);
|
||||||
|
break;
|
||||||
|
case PREF_UPDATE:
|
||||||
|
g_free(*setting);
|
||||||
|
*setting = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void handle_combo_box_entry(GtkWidget *widget, GeanyPrefEntry *entry,
|
||||||
|
PrefAction action)
|
||||||
|
{
|
||||||
|
widget = gtk_bin_get_child(GTK_BIN(widget));
|
||||||
|
handle_entry(widget, entry, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* taken from Glade 2.x generated support.c */
|
/* taken from Glade 2.x generated support.c */
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
lookup_widget (GtkWidget *widget,
|
lookup_widget (GtkWidget *widget,
|
||||||
@ -419,6 +449,10 @@ static void pref_action(PrefAction action, GeanyPrefGroup *group, GtkWidget *own
|
|||||||
handle_spin_button(widget, entry, action);
|
handle_spin_button(widget, entry, action);
|
||||||
else if (entry->widget_type == GTK_TYPE_COMBO_BOX)
|
else if (entry->widget_type == GTK_TYPE_COMBO_BOX)
|
||||||
handle_combo_box(widget, entry, action);
|
handle_combo_box(widget, entry, action);
|
||||||
|
else if (entry->widget_type == GTK_TYPE_COMBO_BOX_ENTRY)
|
||||||
|
handle_combo_box_entry(widget, entry, action);
|
||||||
|
else if (entry->widget_type == GTK_TYPE_ENTRY)
|
||||||
|
handle_entry(widget, entry, action);
|
||||||
else
|
else
|
||||||
g_warning("Unhandled type for %s::%s in %s!", group->name, entry->key_name,
|
g_warning("Unhandled type for %s::%s in %s!", group->name, entry->key_name,
|
||||||
G_GNUC_FUNCTION);
|
G_GNUC_FUNCTION);
|
||||||
@ -524,7 +558,7 @@ void stash_group_add_spin_button_integer(GeanyPrefGroup *group, gint *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: stash_group_add_combo_box_entry(). */
|
/* @see stash_group_add_combo_box_entry(). */
|
||||||
void stash_group_add_combo_box(GeanyPrefGroup *group, gint *setting,
|
void stash_group_add_combo_box(GeanyPrefGroup *group, gint *setting,
|
||||||
const gchar *key_name, gint default_value, gpointer widget_id)
|
const gchar *key_name, gint default_value, gpointer widget_id)
|
||||||
{
|
{
|
||||||
@ -533,3 +567,19 @@ void stash_group_add_combo_box(GeanyPrefGroup *group, gint *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void stash_group_add_combo_box_entry(GeanyPrefGroup *group, gchar **setting,
|
||||||
|
const gchar *key_name, const gchar *default_value, gpointer widget_id)
|
||||||
|
{
|
||||||
|
add_widget_pref(group, G_TYPE_STRING, setting, key_name, (gpointer)default_value,
|
||||||
|
GTK_TYPE_COMBO_BOX_ENTRY, widget_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void stash_group_add_entry(GeanyPrefGroup *group, gchar **setting,
|
||||||
|
const gchar *key_name, const gchar *default_value, gpointer widget_id)
|
||||||
|
{
|
||||||
|
add_widget_pref(group, G_TYPE_STRING, setting, key_name, (gpointer)default_value,
|
||||||
|
GTK_TYPE_ENTRY, widget_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,4 +69,10 @@ void stash_group_add_spin_button_integer(GeanyPrefGroup *group, gint *setting,
|
|||||||
void stash_group_add_combo_box(GeanyPrefGroup *group, gint *setting,
|
void stash_group_add_combo_box(GeanyPrefGroup *group, gint *setting,
|
||||||
const gchar *key_name, gint default_value, gpointer widget_id);
|
const gchar *key_name, gint default_value, gpointer widget_id);
|
||||||
|
|
||||||
|
void stash_group_add_combo_box_entry(GeanyPrefGroup *group, gchar **setting,
|
||||||
|
const gchar *key_name, const gchar *default_value, gpointer widget_id);
|
||||||
|
|
||||||
|
void stash_group_add_entry(GeanyPrefGroup *group, gchar **setting,
|
||||||
|
const gchar *key_name, const gchar *default_value, gpointer widget_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user