Wrapped treeview stuff into an object
parent
9e4ae7a3e8
commit
88a39130f8
|
@ -27,9 +27,9 @@ static void pattern_data_func (GtkTreeViewColumn *column,
|
||||||
GtkCellRenderer *cell,
|
GtkCellRenderer *cell,
|
||||||
GtkTreeModel *model,
|
GtkTreeModel *model,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
static void new_item_func (MooConfig *config,
|
static void new_item (MooConfigHelper *helper,
|
||||||
MooConfigItem *item,
|
MooConfig *config,
|
||||||
gpointer data);
|
MooConfigItem *item);
|
||||||
|
|
||||||
|
|
||||||
static MooPlugin *
|
static MooPlugin *
|
||||||
|
@ -71,6 +71,7 @@ _as_plugin_prefs_page (MooPlugin *plugin)
|
||||||
GtkWidget *treeview;
|
GtkWidget *treeview;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
GtkCellRenderer *cell;
|
GtkCellRenderer *cell;
|
||||||
|
MooConfigHelper *helper;
|
||||||
|
|
||||||
xml = moo_glade_xml_new_empty ();
|
xml = moo_glade_xml_new_empty ();
|
||||||
moo_glade_xml_map_id (xml, "script", MOO_TYPE_TEXT_VIEW);
|
moo_glade_xml_map_id (xml, "script", MOO_TYPE_TEXT_VIEW);
|
||||||
|
@ -97,21 +98,26 @@ _as_plugin_prefs_page (MooPlugin *plugin)
|
||||||
(GtkTreeCellDataFunc) pattern_data_func,
|
(GtkTreeCellDataFunc) pattern_data_func,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
moo_config_connect_widget (treeview,
|
helper = moo_config_helper_new (treeview,
|
||||||
moo_glade_xml_get_widget (xml, "new"),
|
moo_glade_xml_get_widget (xml, "new"),
|
||||||
moo_glade_xml_get_widget (xml, "delete"),
|
moo_glade_xml_get_widget (xml, "delete"),
|
||||||
moo_glade_xml_get_widget (xml, "up"),
|
moo_glade_xml_get_widget (xml, "up"),
|
||||||
moo_glade_xml_get_widget (xml, "down"),
|
moo_glade_xml_get_widget (xml, "down"));
|
||||||
new_item_func, NULL);
|
|
||||||
|
|
||||||
moo_config_add_widget (treeview, moo_glade_xml_get_widget (xml, "pattern"),
|
moo_config_helper_add_widget (helper, moo_glade_xml_get_widget (xml, "pattern"),
|
||||||
AS_KEY_PATTERN, TRUE);
|
AS_KEY_PATTERN, TRUE);
|
||||||
moo_config_add_widget (treeview, moo_glade_xml_get_widget (xml, "lang"),
|
moo_config_helper_add_widget (helper, moo_glade_xml_get_widget (xml, "lang"),
|
||||||
AS_KEY_LANG, FALSE);
|
AS_KEY_LANG, FALSE);
|
||||||
moo_config_add_widget (treeview, moo_glade_xml_get_widget (xml, "enabled"),
|
moo_config_helper_add_widget (helper, moo_glade_xml_get_widget (xml, "enabled"),
|
||||||
AS_KEY_ENABLED, TRUE);
|
AS_KEY_ENABLED, TRUE);
|
||||||
moo_config_add_widget (treeview, moo_glade_xml_get_widget (xml, "script"),
|
moo_config_helper_add_widget (helper, moo_glade_xml_get_widget (xml, "script"),
|
||||||
NULL, FALSE);
|
NULL, FALSE);
|
||||||
|
|
||||||
|
g_signal_connect (helper, "new-item",
|
||||||
|
G_CALLBACK (new_item), NULL);
|
||||||
|
g_object_set_data_full (G_OBJECT (treeview),
|
||||||
|
"as-plugin-config-helper",
|
||||||
|
helper, g_object_unref);
|
||||||
|
|
||||||
g_object_unref (xml);
|
g_object_unref (xml);
|
||||||
return page;
|
return page;
|
||||||
|
@ -146,10 +152,12 @@ prefs_page_apply (MooGladeXML *xml)
|
||||||
{
|
{
|
||||||
GtkWidget *treeview;
|
GtkWidget *treeview;
|
||||||
MooConfig *config;
|
MooConfig *config;
|
||||||
|
MooConfigHelper *helper;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
treeview = moo_glade_xml_get_widget (xml, "treeview");
|
treeview = moo_glade_xml_get_widget (xml, "treeview");
|
||||||
moo_config_update_tree_view (treeview, NULL, NULL);
|
helper = g_object_get_data (G_OBJECT (treeview), "as-plugin-config-helper");
|
||||||
|
moo_config_helper_update_model (helper, NULL, NULL);
|
||||||
|
|
||||||
config = MOO_CONFIG (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
|
config = MOO_CONFIG (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
|
||||||
|
|
||||||
|
@ -191,9 +199,9 @@ prefs_page_init (MooGladeXML *xml)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
new_item_func (MooConfig *config,
|
new_item (G_GNUC_UNUSED MooConfigHelper *helper,
|
||||||
MooConfigItem *item,
|
MooConfig *config,
|
||||||
G_GNUC_UNUSED gpointer data)
|
MooConfigItem *item)
|
||||||
{
|
{
|
||||||
moo_config_set (config, item, AS_KEY_PATTERN, "?", TRUE);
|
moo_config_set (config, item, AS_KEY_PATTERN, "?", TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ BOOL:BOXED,UINT
|
||||||
BOOL:ENUM,INT,BOOL
|
BOOL:ENUM,INT,BOOL
|
||||||
BOOL:INT
|
BOOL:INT
|
||||||
BOOL:OBJECT,BOXED
|
BOOL:OBJECT,BOXED
|
||||||
|
BOOL:OBJECT,BOXED,BOXED
|
||||||
BOOL:OBJECT,OBJECT
|
BOOL:OBJECT,OBJECT
|
||||||
BOOL:POINTER
|
BOOL:POINTER
|
||||||
BOOL:STRING
|
BOOL:STRING
|
||||||
|
@ -26,7 +27,9 @@ VOID:ENUM,UINT
|
||||||
VOID:INT
|
VOID:INT
|
||||||
VOID:OBJECT
|
VOID:OBJECT
|
||||||
VOID:OBJECT,BOXED
|
VOID:OBJECT,BOXED
|
||||||
|
VOID:OBJECT,BOXED,BOXED
|
||||||
VOID:OBJECT,OBJECT
|
VOID:OBJECT,OBJECT
|
||||||
|
VOID:OBJECT,POINTER
|
||||||
VOID:POINTER
|
VOID:POINTER
|
||||||
VOID:POINTER,BOOL
|
VOID:POINTER,BOOL
|
||||||
VOID:POINTER,INT
|
VOID:POINTER,INT
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,44 +20,67 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
typedef void (*MooConfigSetupItemFunc) (MooConfig *config,
|
typedef struct _MooTreeHelper MooTreeHelper;
|
||||||
MooConfigItem *item,
|
typedef struct _MooConfigHelper MooConfigHelper;
|
||||||
gpointer data);
|
typedef struct _MooTreeHelperClass MooTreeHelperClass;
|
||||||
typedef void (*MooConfigWidgetToItem) (GtkWidget *widget,
|
typedef struct _MooConfigHelperClass MooConfigHelperClass;
|
||||||
MooConfig *config,
|
|
||||||
MooConfigItem *item,
|
|
||||||
gpointer data);
|
|
||||||
typedef void (*MooConfigItemToWidget) (MooConfig *config,
|
|
||||||
MooConfigItem *item,
|
|
||||||
GtkWidget *widget,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
void moo_config_connect_widget (GtkWidget *tree_view,
|
struct _MooTreeHelperClass {
|
||||||
GtkWidget *new_btn,
|
GtkObjectClass parent_class;
|
||||||
GtkWidget *delete_btn,
|
|
||||||
GtkWidget *up_btn,
|
gboolean (*new_row) (MooTreeHelper *helper,
|
||||||
GtkWidget *down_btn,
|
GtkTreeModel *model,
|
||||||
MooConfigSetupItemFunc func,
|
GtkTreePath *path);
|
||||||
gpointer data);
|
gboolean (*delete_row) (MooTreeHelper *helper,
|
||||||
void moo_config_add_widget (GtkWidget *tree_view,
|
GtkTreeModel *model,
|
||||||
GtkWidget *widget,
|
GtkTreePath *path);
|
||||||
const char *key,
|
gboolean (*move_row) (MooTreeHelper *helper,
|
||||||
gboolean update_live);
|
GtkTreeModel *model,
|
||||||
void moo_config_add_widget_full (GtkWidget *tree_view,
|
GtkTreePath *old_path,
|
||||||
GtkWidget *widget,
|
GtkTreePath *new_path);
|
||||||
const char *key,
|
|
||||||
MooConfigWidgetToItem widget_to_item_func,
|
void (*update_widgets) (MooTreeHelper *helper,
|
||||||
MooConfigItemToWidget item_to_widget_func,
|
GtkTreeModel *model,
|
||||||
gpointer data,
|
GtkTreePath *path,
|
||||||
gboolean update_live);
|
GtkTreeIter *iter);
|
||||||
void moo_config_disconnect_widget(GtkWidget *tree_view);
|
void (*update_model) (MooTreeHelper *helper,
|
||||||
void moo_config_update_tree_view (GtkWidget *tree_view,
|
GtkTreeModel *model,
|
||||||
GtkTreeModel *model,
|
GtkTreePath *path,
|
||||||
GtkTreePath *path);
|
GtkTreeIter *iter);
|
||||||
void moo_config_update_widgets (GtkWidget *tree_view);
|
};
|
||||||
|
|
||||||
|
struct _MooConfigHelperClass {
|
||||||
|
MooTreeHelperClass parent_class;
|
||||||
|
|
||||||
|
void (*new_item) (MooConfigHelper *helper,
|
||||||
|
MooConfig *config,
|
||||||
|
MooConfigItem *item);
|
||||||
|
void (*set_from_item) (MooConfigHelper *helper,
|
||||||
|
MooConfig *config,
|
||||||
|
MooConfigItem *item);
|
||||||
|
void (*set_from_widgets) (MooConfigHelper *helper,
|
||||||
|
MooConfig *config,
|
||||||
|
MooConfigItem *item);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void moo_tree_view_select_first (GtkTreeView *tree_view);
|
MooConfigHelper *moo_config_helper_new (GtkWidget *tree_view,
|
||||||
|
GtkWidget *new_btn,
|
||||||
|
GtkWidget *delete_btn,
|
||||||
|
GtkWidget *up_btn,
|
||||||
|
GtkWidget *down_btn);
|
||||||
|
|
||||||
|
void moo_config_helper_add_widget (MooConfigHelper *helper,
|
||||||
|
GtkWidget *widget,
|
||||||
|
const char *key,
|
||||||
|
gboolean update_live);
|
||||||
|
void moo_config_helper_update_model (MooConfigHelper *helper,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreePath *path);
|
||||||
|
void moo_config_helper_update_widgets (MooConfigHelper *helper);
|
||||||
|
|
||||||
|
|
||||||
|
void moo_tree_view_select_first (GtkTreeView *tree_view);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue