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