{
/* IM configuration widget created by mim_config_new (). */
GtkWidget *config;
+ /* Button widget "default" */
+ GtkWidget *default_;
/* Button widget "revert" */
GtkWidget *revert;
/* Button widget "save" */
}
}
+/* Called when "default" button is clicked. */
+static void
+default_clicked_cb (GtkButton *button, gpointer data)
+{
+ struct CallbackArgument *arg = data;
+
+ mim_config_default (arg->config);
+ status_changed_cb (arg->config, data);
+}
+
/* Called when "revert" button is clicked. */
static void
revert_clicked_cb (GtkButton *button, gpointer data)
main (int argc, char **argv)
{
GtkWidget *window, *vbox, *hbox;
- GtkWidget *revert, *save, *ok, *quit;
+ GtkWidget *default_, *revert, *save, *ok, *quit;
struct CallbackArgument arg;
#if ENABLE_NLS
|| ||
|+-------------------------------------+|
|+-hbox--------------------------------+|
- || +------+ +----+ +----+ +--+||
- || |revert| |save| |quit| |ok|||
- || +------+ +----+ +----+ +--+||
+ ||+-------+ +------+ +----+ +----+ +--+||
+ |||default| |revert| |save| |quit| |ok|||
+ ||+-------+ +------+ +----+ +----+ +--+||
|+-------------------------------------+|
+---------------------------------------+
*/
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_container_add (GTK_CONTAINER (window), vbox);
+ default_ = gtk_button_new_from_stock (_("_Default"));
revert = gtk_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
gtk_widget_set_sensitive (revert, FALSE);
save = gtk_button_new_from_stock (GTK_STOCK_SAVE);
arg.config = mim_config_new (G_CALLBACK (status_changed_cb), &arg);
gtk_box_pack_start (GTK_BOX (vbox), arg.config, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (default_), "clicked",
+ G_CALLBACK (default_clicked_cb), &arg);
g_signal_connect (G_OBJECT (revert), "clicked",
G_CALLBACK (revert_clicked_cb), &arg);
g_signal_connect (G_OBJECT (save), "clicked",
hbox = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
gtk_box_set_spacing (GTK_BOX (hbox), 5);
+ gtk_container_add (GTK_CONTAINER (hbox), default_);
gtk_container_add (GTK_CONTAINER (hbox), revert);
gtk_container_add (GTK_CONTAINER (hbox), save);
gtk_container_add (GTK_CONTAINER (hbox), quit);
static gboolean
revert_to_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
- gpointer data)
+ gpointer data)
{
enum MimStatus status;
MSymbol lang, name;
static gboolean
set_as_saved (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
- gpointer data)
+ gpointer data)
{
enum MimStatus status;
MSymbol lang, name;
return FALSE;
}
+static gboolean
+reset_to_default (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
+ gpointer data)
+{
+ enum MimStatus status;
+ MSymbol lang, name;
+ MimConfigStatus *config_status = data;
+ MPlist *empty = mplist ();
+
+ gtk_tree_model_get (model, iter, COL_LANG, &lang, COL_NAME, &name, -1);
+ if (lang == Mnil)
+ return FALSE;
+ gtk_tree_model_get (model, iter, COL_STATUS, &status, -1);
+ if (status == MIM_STATUS_DEFAULT)
+ return FALSE;
+ minput_config_variable (lang, name, Mnil, empty);
+ minput_config_command (lang, name, Mnil, empty);
+ status = get_mim_status (lang, name);
+ update_child_row (model, iter, status, config_status, NULL);
+ return FALSE;
+}
+
static int initialized = 0;
static void
}
gboolean
+mim_config_default (GtkWidget *config)
+{
+ GtkTreeView *tree;
+ GtkTreeModel *model;
+ MimConfigStatus *config_status;
+
+ tree = g_object_get_data (G_OBJECT (config), CONFIG_TREE_VIEW);
+ model = gtk_tree_view_get_model (tree);
+ config_status = g_object_get_data (G_OBJECT (model), CONFIG_STATUS_DATA);
+ gtk_tree_model_foreach (model, reset_to_default, config_status);
+ return TRUE;
+}
+
+gboolean
mim_config_revert (GtkWidget *config)
{
GtkTreeView *tree;