2006-08-16 20:27:19 -05:00
|
|
|
/*
|
|
|
|
* moousertools-prefs.c
|
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* Copyright (C) 2004-2008 by Yevgen Muntyan <muntyan@tamu.edu>
|
2006-08-16 20:27:19 -05:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* This file is part of medit. medit is free software; you can
|
|
|
|
* redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2.1 of the License,
|
|
|
|
* or (at your option) any later version.
|
2006-08-16 20:27:19 -05:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-16 20:27:19 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mooedit/moousertools-prefs.h"
|
|
|
|
#include "mooedit/moousertools.h"
|
|
|
|
#include "mooedit/moocommand.h"
|
2006-08-17 00:08:49 -05:00
|
|
|
#include "mooedit/moocommanddisplay.h"
|
2008-08-30 13:53:46 -05:00
|
|
|
#include "mooutils/mooprefspage.h"
|
2006-08-16 20:27:19 -05:00
|
|
|
#include "mooutils/mooi18n.h"
|
|
|
|
#include "mooutils/mooutils-treeview.h"
|
2007-09-07 23:59:37 -05:00
|
|
|
#include "mooutils/moohelp.h"
|
2008-08-30 13:53:46 -05:00
|
|
|
#include "glade/moousertools-gxml.h"
|
2007-11-22 16:07:19 -06:00
|
|
|
#include "help-sections.h"
|
2006-08-16 20:27:19 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
enum {
|
2006-08-17 23:53:34 -05:00
|
|
|
COLUMN_INFO,
|
2006-08-16 20:27:19 -05:00
|
|
|
N_COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
static MooUserToolType
|
2008-08-30 13:53:46 -05:00
|
|
|
page_get_type (MooPrefsPage *page)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
|
|
|
return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page), "moo-user-tool-type"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
page_set_type (MooPrefsPage *page,
|
|
|
|
MooUserToolType type)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (page), "moo-user-tool-type", GINT_TO_POINTER (type));
|
|
|
|
}
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-08-30 13:53:46 -05:00
|
|
|
get_changed (MooPrefsPage *page)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
|
|
|
return g_object_get_data (G_OBJECT (page), "moo-changed") != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
set_changed (MooPrefsPage *page,
|
|
|
|
gboolean changed)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2006-08-17 23:53:34 -05:00
|
|
|
g_object_set_data (G_OBJECT (page), "moo-changed", GINT_TO_POINTER (changed));
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-17 00:08:49 -05:00
|
|
|
static MooCommandDisplay *
|
2008-08-30 13:53:46 -05:00
|
|
|
get_helper (MooPrefsPage *page)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2006-08-17 00:08:49 -05:00
|
|
|
return g_object_get_data (G_OBJECT (page), "moo-tree-helper");
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-19 00:21:29 -05:00
|
|
|
populate_store (GtkListStore *store,
|
|
|
|
MooUserToolType type)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
2006-08-19 00:21:29 -05:00
|
|
|
GSList *list;
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2007-11-23 01:23:53 -06:00
|
|
|
list = _moo_edit_parse_user_tools (type, FALSE);
|
2006-08-19 00:21:29 -05:00
|
|
|
|
|
|
|
while (list)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
2006-08-19 00:21:29 -05:00
|
|
|
MooUserToolInfo *info = list->data;
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-19 00:21:29 -05:00
|
|
|
if (info->os_type == MOO_USER_TOOL_THIS_OS)
|
|
|
|
{
|
|
|
|
gtk_list_store_append (store, &iter);
|
|
|
|
gtk_list_store_set (store, &iter, COLUMN_INFO, info, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
_moo_user_tool_info_unref (info);
|
|
|
|
list = g_slist_delete_link (list, list);
|
|
|
|
}
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-08-30 13:53:46 -05:00
|
|
|
new_row (MooPrefsPage *page,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
2006-08-17 23:53:34 -05:00
|
|
|
MooUserToolInfo *info;
|
2006-08-19 00:21:29 -05:00
|
|
|
GtkTreeViewColumn *column;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
|
|
|
|
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
info = _moo_user_tool_info_new ();
|
2007-09-02 15:42:17 -05:00
|
|
|
info->cmd_factory = moo_command_factory_lookup ("lua");
|
2007-02-27 22:23:57 -06:00
|
|
|
info->cmd_data = info->cmd_factory ? moo_command_data_new (info->cmd_factory->n_keys) : NULL;
|
2006-08-20 03:49:33 -05:00
|
|
|
info->name = g_strdup (_("New Command"));
|
|
|
|
info->options = g_strdup ("need-doc");
|
2006-08-17 23:53:34 -05:00
|
|
|
info->enabled = TRUE;
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
set_changed (page, TRUE);
|
|
|
|
gtk_list_store_insert (GTK_LIST_STORE (model), &iter,
|
|
|
|
gtk_tree_path_get_indices(path)[0]);
|
2006-08-17 23:53:34 -05:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_INFO, info, -1);
|
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
column = gtk_tree_view_get_column (gxml->treeview, 0);
|
|
|
|
gtk_tree_view_set_cursor (gxml->treeview, path, column, TRUE);
|
2006-08-19 00:21:29 -05:00
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
_moo_user_tool_info_unref (info);
|
2006-08-16 20:27:19 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-08-23 02:39:03 -05:00
|
|
|
static gboolean
|
2008-08-30 13:53:46 -05:00
|
|
|
delete_row (MooPrefsPage *page)
|
2006-08-23 02:39:03 -05:00
|
|
|
{
|
|
|
|
set_changed (page, TRUE);
|
2006-08-23 02:40:45 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2008-08-30 13:53:46 -05:00
|
|
|
move_row (MooPrefsPage *page)
|
2006-08-23 02:40:45 -05:00
|
|
|
{
|
|
|
|
set_changed (page, TRUE);
|
|
|
|
return FALSE;
|
2006-08-23 02:39:03 -05:00
|
|
|
}
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
update_widgets (MooPrefsPage *page,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2006-08-17 00:08:49 -05:00
|
|
|
MooCommandDisplay *helper;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
2006-08-17 00:08:49 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-17 00:08:49 -05:00
|
|
|
helper = get_helper (page);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
if (path)
|
|
|
|
{
|
2006-08-17 23:53:34 -05:00
|
|
|
MooUserToolInfo *info;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, COLUMN_INFO, &info, -1);
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
2007-02-27 22:23:57 -06:00
|
|
|
_moo_command_display_set (helper, info->cmd_factory, info->cmd_data);
|
2006-08-17 23:53:34 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gxml->enabled), info->enabled);
|
|
|
|
gtk_entry_set_text (gxml->filter, info->filter ? info->filter : "");
|
|
|
|
gtk_entry_set_text (gxml->options, info->options ? info->options : "");
|
2006-08-17 23:53:34 -05:00
|
|
|
|
|
|
|
_moo_user_tool_info_unref (info);
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gxml->enabled), FALSE);
|
|
|
|
gtk_entry_set_text (gxml->filter, "");
|
|
|
|
gtk_entry_set_text (gxml->options, "");
|
2006-08-17 00:08:49 -05:00
|
|
|
_moo_command_display_set (helper, NULL, NULL);
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
2006-08-17 23:53:34 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (gxml->tool_vbox), path != NULL);
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
2006-08-17 23:53:34 -05:00
|
|
|
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
static gboolean
|
2008-08-30 13:53:46 -05:00
|
|
|
get_text (GtkEntry *entry,
|
|
|
|
char **dest)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
const char *text = gtk_entry_get_text (entry);
|
2006-08-17 23:53:34 -05:00
|
|
|
|
|
|
|
if (strcmp (*dest ? *dest : "", text) != 0)
|
|
|
|
{
|
|
|
|
g_free (*dest);
|
|
|
|
*dest = text[0] ? g_strdup (text) : NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
update_model (MooPrefsPage *page,
|
|
|
|
GtkTreeModel *model,
|
2006-08-16 20:27:19 -05:00
|
|
|
G_GNUC_UNUSED GtkTreePath *path,
|
2008-08-30 13:53:46 -05:00
|
|
|
GtkTreeIter *iter)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2006-08-17 00:08:49 -05:00
|
|
|
MooCommandDisplay *helper;
|
2007-02-27 22:23:57 -06:00
|
|
|
MooCommandFactory *factory;
|
2006-08-16 20:27:19 -05:00
|
|
|
MooCommandData *data;
|
2006-08-17 23:53:34 -05:00
|
|
|
MooUserToolInfo *info;
|
|
|
|
gboolean changed = FALSE;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
|
|
|
|
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-17 00:08:49 -05:00
|
|
|
helper = get_helper (page);
|
2006-08-17 23:53:34 -05:00
|
|
|
gtk_tree_model_get (model, iter, COLUMN_INFO, &info, -1);
|
|
|
|
g_return_if_fail (info != NULL);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2007-02-27 22:23:57 -06:00
|
|
|
if (_moo_command_display_get (helper, &factory, &data))
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2006-08-17 23:53:34 -05:00
|
|
|
moo_command_data_unref (info->cmd_data);
|
|
|
|
info->cmd_data = moo_command_data_ref (data);
|
2007-02-27 22:23:57 -06:00
|
|
|
info->cmd_factory = factory;
|
2006-08-17 23:53:34 -05:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), iter, COLUMN_INFO, info, -1);
|
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gxml->enabled)) != info->enabled)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
info->enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gxml->enabled));
|
2006-08-17 23:53:34 -05:00
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
changed = get_text (gxml->filter, &info->filter) || changed;
|
|
|
|
changed = get_text (gxml->options, &info->options) || changed;
|
2006-08-17 23:53:34 -05:00
|
|
|
|
|
|
|
if (changed)
|
|
|
|
{
|
2007-11-26 22:03:43 -06:00
|
|
|
info->builtin = FALSE;
|
2006-08-16 20:27:19 -05:00
|
|
|
set_changed (page, TRUE);
|
|
|
|
}
|
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
_moo_user_tool_info_unref (info);
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-17 23:53:34 -05:00
|
|
|
name_data_func (G_GNUC_UNUSED GtkTreeViewColumn *column,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
MooUserToolInfo *info = NULL;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, COLUMN_INFO, &info, -1);
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
|
|
|
g_object_set (cell, "text", info->name, NULL);
|
|
|
|
|
|
|
|
_moo_user_tool_info_unref (info);
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:21:29 -05:00
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
name_cell_edited (MooPrefsPage *page,
|
|
|
|
char *path_string,
|
|
|
|
char *text)
|
2006-08-19 00:21:29 -05:00
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
MooUserToolInfo *info = NULL;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
|
|
|
|
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-19 00:21:29 -05:00
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_string);
|
2008-08-30 13:53:46 -05:00
|
|
|
model = gtk_tree_view_get_model (gxml->treeview);
|
2006-08-19 00:21:29 -05:00
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, COLUMN_INFO, &info, -1);
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
|
|
|
if (strcmp (info->name ? info->name : "", text) != 0)
|
|
|
|
{
|
|
|
|
set_changed (page, TRUE);
|
|
|
|
g_free (info->name);
|
|
|
|
info->name = g_strdup (text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
command_page_init (MooPrefsPage *page,
|
|
|
|
MooUserToolType type)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *cell;
|
2006-08-17 00:08:49 -05:00
|
|
|
MooCommandDisplay *helper;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
|
|
|
|
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
page_set_type (page, type);
|
|
|
|
|
|
|
|
store = gtk_list_store_new (N_COLUMNS, MOO_TYPE_USER_TOOL_INFO);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
2006-08-17 23:53:34 -05:00
|
|
|
column = gtk_tree_view_column_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, cell, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, cell,
|
|
|
|
(GtkTreeCellDataFunc) name_data_func,
|
|
|
|
NULL, NULL);
|
2008-08-30 13:53:46 -05:00
|
|
|
gtk_tree_view_append_column (gxml->treeview, column);
|
2006-08-19 00:21:29 -05:00
|
|
|
g_object_set (cell, "editable", TRUE, NULL);
|
|
|
|
g_signal_connect_swapped (cell, "edited", G_CALLBACK (name_cell_edited), page);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
populate_store (store, type);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
helper = _moo_command_display_new (gxml->type_combo,
|
|
|
|
gxml->type_notebook,
|
|
|
|
GTK_WIDGET (gxml->treeview),
|
|
|
|
GTK_WIDGET (gxml->new_),
|
|
|
|
GTK_WIDGET (gxml->delete_),
|
|
|
|
GTK_WIDGET (gxml->up),
|
|
|
|
GTK_WIDGET (gxml->down));
|
2006-08-16 20:27:19 -05:00
|
|
|
g_object_set_data_full (G_OBJECT (page), "moo-tree-helper", helper, g_object_unref);
|
|
|
|
g_signal_connect_swapped (page, "destroy", G_CALLBACK (gtk_object_destroy), helper);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (helper, "new-row", G_CALLBACK (new_row), page);
|
2006-08-23 02:39:03 -05:00
|
|
|
g_signal_connect_swapped (helper, "delete-row", G_CALLBACK (delete_row), page);
|
2006-08-23 02:40:45 -05:00
|
|
|
g_signal_connect_swapped (helper, "move-row", G_CALLBACK (move_row), page);
|
2006-08-16 20:27:19 -05:00
|
|
|
g_signal_connect_swapped (helper, "update-widgets", G_CALLBACK (update_widgets), page);
|
|
|
|
g_signal_connect_swapped (helper, "update-model", G_CALLBACK (update_model), page);
|
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
gtk_tree_view_set_model (gxml->treeview, GTK_TREE_MODEL (store));
|
2007-06-14 02:18:35 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
_moo_tree_view_select_first (gxml->treeview);
|
2006-08-17 00:08:49 -05:00
|
|
|
_moo_tree_helper_update_widgets (MOO_TREE_HELPER (helper));
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
command_page_apply (MooPrefsPage *page)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
|
|
|
MooTreeHelper *helper;
|
2006-08-17 23:53:34 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GSList *list = NULL;
|
2008-08-30 13:53:46 -05:00
|
|
|
CommandXml *gxml;
|
|
|
|
|
|
|
|
gxml = g_object_get_data (G_OBJECT (page), "moo-user-tools-prefs-xml");
|
2006-08-16 20:27:19 -05:00
|
|
|
|
|
|
|
helper = g_object_get_data (G_OBJECT (page), "moo-tree-helper");
|
|
|
|
_moo_tree_helper_update_model (helper, NULL, NULL);
|
|
|
|
|
|
|
|
if (!get_changed (page))
|
|
|
|
return;
|
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
model = gtk_tree_view_get_model (gxml->treeview);
|
2006-08-17 23:53:34 -05:00
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
MooUserToolInfo *info;
|
|
|
|
gtk_tree_model_get (model, &iter, COLUMN_INFO, &info, -1);
|
|
|
|
list = g_slist_prepend (list, info);
|
|
|
|
}
|
|
|
|
while (gtk_tree_model_iter_next (model, &iter));
|
|
|
|
}
|
|
|
|
|
|
|
|
list = g_slist_reverse (list);
|
|
|
|
|
|
|
|
_moo_edit_save_user_tools (page_get_type (page), list);
|
2008-01-09 21:14:10 -06:00
|
|
|
_moo_edit_load_user_tools_type (page_get_type (page));
|
2006-08-17 23:53:34 -05:00
|
|
|
|
|
|
|
g_slist_foreach (list, (GFunc) _moo_user_tool_info_unref, NULL);
|
|
|
|
g_slist_free (list);
|
|
|
|
|
2006-08-16 20:27:19 -05:00
|
|
|
set_changed (page, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-17 23:53:34 -05:00
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
main_page_init (PrefsPageXml *gxml)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
command_page_init (gxml->page_menu, MOO_USER_TOOL_MENU);
|
|
|
|
command_page_init (gxml->page_context, MOO_USER_TOOL_CONTEXT);
|
2006-08-17 23:53:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-30 13:53:46 -05:00
|
|
|
main_page_apply (PrefsPageXml *gxml)
|
2006-08-17 23:53:34 -05:00
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
command_page_apply (gxml->page_menu);
|
|
|
|
command_page_apply (gxml->page_context);
|
2006-08-17 23:53:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-16 20:27:19 -05:00
|
|
|
GtkWidget *
|
2007-09-02 15:42:17 -05:00
|
|
|
moo_user_tools_prefs_page_new (void)
|
2006-08-16 20:27:19 -05:00
|
|
|
{
|
2008-08-30 13:53:46 -05:00
|
|
|
GtkWidget *page;
|
|
|
|
PrefsPageXml *gxml;
|
|
|
|
CommandXml *cxml;
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
page = moo_prefs_page_new (_("Tools"), GTK_STOCK_EXECUTE);
|
|
|
|
gxml = prefs_page_xml_new_with_root (page);
|
2008-08-24 01:54:32 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
g_signal_connect_swapped (page, "init", G_CALLBACK (main_page_init), gxml);
|
|
|
|
g_signal_connect_swapped (page, "apply", G_CALLBACK (main_page_apply), gxml);
|
|
|
|
moo_help_set_id (page, HELP_SECTION_PREFS_USER_TOOLS);
|
2006-08-17 23:53:34 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
cxml = command_xml_new_with_root (GTK_WIDGET (gxml->page_menu));
|
|
|
|
g_object_set_data (G_OBJECT (gxml->page_menu), "moo-user-tools-prefs-xml", cxml);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
cxml = command_xml_new_with_root (GTK_WIDGET (gxml->page_context));
|
|
|
|
g_object_set_data (G_OBJECT (gxml->page_context), "moo-user-tools-prefs-xml", cxml);
|
2006-08-16 20:27:19 -05:00
|
|
|
|
2008-08-30 13:53:46 -05:00
|
|
|
return page;
|
2006-08-16 20:27:19 -05:00
|
|
|
}
|