preferences-dialog: Clean up code styling

This commit is contained in:
JosephMcc 2016-12-30 11:54:48 -08:00
parent f3791ef8d2
commit 05738f44bb
1 changed files with 667 additions and 794 deletions

View File

@ -153,14 +153,9 @@ dialog_response_handler (GtkDialog *dlg,
switch (res_id)
{
case GTK_RESPONSE_HELP:
xed_help_display (GTK_WINDOW (dlg),
NULL,
"xed-prefs");
xed_help_display (GTK_WINDOW (dlg), NULL, "xed-prefs");
g_signal_stop_emission_by_name (dlg, "response");
break;
default:
gtk_widget_destroy (GTK_WIDGET(dlg));
}
@ -209,9 +204,7 @@ auto_save_checkbutton_toggled (GtkToggleButton *button,
if (gtk_toggle_button_get_active (button))
{
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton,
xed_prefs_manager_auto_save_interval_can_set());
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, xed_prefs_manager_auto_save_interval_can_set());
xed_prefs_manager_set_auto_save (TRUE);
}
else
@ -238,8 +231,7 @@ auto_save_spinbutton_value_changed (GtkSpinButton *spin_button,
{
g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton));
xed_prefs_manager_set_auto_save_interval (
MAX (1, gtk_spin_button_get_value_as_int (spin_button)));
xed_prefs_manager_set_auto_save_interval (MAX (1, gtk_spin_button_get_value_as_int (spin_button)));
}
static void
@ -261,64 +253,45 @@ setup_editor_page (XedPreferencesDialog *dlg)
xed_prefs_manager_get_create_backup_copy ());
auto_save = xed_prefs_manager_get_auto_save ();
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton),
auto_save);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton), auto_save);
auto_save_interval = xed_prefs_manager_get_auto_save_interval ();
if (auto_save_interval <= 0)
{
auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL;
}
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton),
auto_save_interval);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton), auto_save_interval);
/* Set widget sensitivity */
gtk_widget_set_sensitive (dlg->priv->tabs_width_hbox,
xed_prefs_manager_tabs_size_can_set ());
gtk_widget_set_sensitive (dlg->priv->insert_spaces_checkbutton,
xed_prefs_manager_insert_spaces_can_set ());
gtk_widget_set_sensitive (dlg->priv->auto_indent_checkbutton,
xed_prefs_manager_auto_indent_can_set ());
gtk_widget_set_sensitive (dlg->priv->backup_copy_checkbutton,
xed_prefs_manager_create_backup_copy_can_set ());
gtk_widget_set_sensitive (dlg->priv->autosave_hbox,
xed_prefs_manager_auto_save_can_set ());
gtk_widget_set_sensitive (dlg->priv->tabs_width_hbox, xed_prefs_manager_tabs_size_can_set ());
gtk_widget_set_sensitive (dlg->priv->insert_spaces_checkbutton, xed_prefs_manager_insert_spaces_can_set ());
gtk_widget_set_sensitive (dlg->priv->auto_indent_checkbutton, xed_prefs_manager_auto_indent_can_set ());
gtk_widget_set_sensitive (dlg->priv->backup_copy_checkbutton, xed_prefs_manager_create_backup_copy_can_set ());
gtk_widget_set_sensitive (dlg->priv->autosave_hbox, xed_prefs_manager_auto_save_can_set ());
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton,
auto_save &&
xed_prefs_manager_auto_save_interval_can_set ());
auto_save && xed_prefs_manager_auto_save_interval_can_set ());
/* Connect signal */
g_signal_connect (dlg->priv->tabs_width_spinbutton,
"value_changed",
G_CALLBACK (tabs_width_spinbutton_value_changed),
dlg);
g_signal_connect (dlg->priv->insert_spaces_checkbutton,
"toggled",
G_CALLBACK (insert_spaces_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->auto_indent_checkbutton,
"toggled",
G_CALLBACK (auto_indent_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->auto_save_checkbutton,
"toggled",
G_CALLBACK (auto_save_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->backup_copy_checkbutton,
"toggled",
G_CALLBACK (backup_copy_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->auto_save_spinbutton,
"value_changed",
G_CALLBACK (auto_save_spinbutton_value_changed),
dlg);
g_signal_connect (dlg->priv->tabs_width_spinbutton, "value_changed",
G_CALLBACK (tabs_width_spinbutton_value_changed), dlg);
g_signal_connect (dlg->priv->insert_spaces_checkbutton, "toggled",
G_CALLBACK (insert_spaces_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->auto_indent_checkbutton, "toggled",
G_CALLBACK (auto_indent_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->auto_save_checkbutton, "toggled",
G_CALLBACK (auto_save_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->backup_copy_checkbutton, "toggled",
G_CALLBACK (backup_copy_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->auto_save_spinbutton, "value_changed",
G_CALLBACK (auto_save_spinbutton_value_changed), dlg);
}
static void
display_line_numbers_checkbutton_toggled (GtkToggleButton *button,
XedPreferencesDialog *dlg)
{
g_return_if_fail (button ==
GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton));
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton));
xed_prefs_manager_set_display_line_numbers (gtk_toggle_button_get_active (button));
}
@ -327,8 +300,7 @@ static void
highlight_current_line_checkbutton_toggled (GtkToggleButton *button,
XedPreferencesDialog *dlg)
{
g_return_if_fail (button ==
GTK_TOGGLE_BUTTON (dlg->priv->highlight_current_line_checkbutton));
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->highlight_current_line_checkbutton));
xed_prefs_manager_set_highlight_current_line (gtk_toggle_button_get_active (button));
}
@ -337,11 +309,9 @@ static void
bracket_matching_checkbutton_toggled (GtkToggleButton *button,
XedPreferencesDialog *dlg)
{
g_return_if_fail (button ==
GTK_TOGGLE_BUTTON (dlg->priv->bracket_matching_checkbutton));
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->bracket_matching_checkbutton));
xed_prefs_manager_set_bracket_matching (
gtk_toggle_button_get_active (button));
xed_prefs_manager_set_bracket_matching (gtk_toggle_button_get_active (button));
}
static gboolean split_button_state = TRUE;
@ -354,30 +324,23 @@ wrap_mode_checkbutton_toggled (GtkToggleButton *button,
{
xed_prefs_manager_set_wrap_mode (GTK_WRAP_NONE);
gtk_widget_set_sensitive (dlg->priv->split_checkbutton,
FALSE);
gtk_toggle_button_set_inconsistent (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, FALSE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
}
else
{
gtk_widget_set_sensitive (dlg->priv->split_checkbutton,
TRUE);
gtk_toggle_button_set_inconsistent (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, TRUE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton)))
{
split_button_state = TRUE;
xed_prefs_manager_set_wrap_mode (GTK_WRAP_WORD);
}
else
{
split_button_state = FALSE;
xed_prefs_manager_set_wrap_mode (GTK_WRAP_CHAR);
}
}
@ -396,8 +359,7 @@ right_margin_checkbutton_toggled (GtkToggleButton *button,
xed_prefs_manager_set_display_right_margin (active);
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox,
active &&
xed_prefs_manager_right_margin_position_can_set ());
active && xed_prefs_manager_right_margin_position_can_set ());
}
static void
@ -436,35 +398,25 @@ setup_view_page (XedPreferencesDialog *dlg)
switch (wrap_mode )
{
case GTK_WRAP_WORD:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
break;
case GTK_WRAP_CHAR:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
break;
default:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), FALSE);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), split_button_state);
gtk_toggle_button_set_inconsistent (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), split_button_state);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
}
display_right_margin = xed_prefs_manager_get_display_right_margin ();
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton),
display_right_margin);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton), display_right_margin);
gtk_spin_button_set_value (
GTK_SPIN_BUTTON (dlg->priv->right_margin_position_spinbutton),
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->right_margin_position_spinbutton),
(guint)CLAMP (xed_prefs_manager_get_right_margin_position (), 1, 160));
/* Set widgets sensitivity */
@ -472,49 +424,29 @@ setup_view_page (XedPreferencesDialog *dlg)
xed_prefs_manager_display_line_numbers_can_set ());
gtk_widget_set_sensitive (dlg->priv->highlight_current_line_checkbutton,
xed_prefs_manager_highlight_current_line_can_set ());
gtk_widget_set_sensitive (dlg->priv->bracket_matching_checkbutton,
xed_prefs_manager_bracket_matching_can_set ());
gtk_widget_set_sensitive (dlg->priv->bracket_matching_checkbutton, xed_prefs_manager_bracket_matching_can_set ());
wrap_mode_can_set = xed_prefs_manager_wrap_mode_can_set ();
gtk_widget_set_sensitive (dlg->priv->wrap_text_checkbutton,
wrap_mode_can_set);
gtk_widget_set_sensitive (dlg->priv->split_checkbutton,
wrap_mode_can_set &&
(wrap_mode != GTK_WRAP_NONE));
gtk_widget_set_sensitive (dlg->priv->right_margin_checkbutton,
xed_prefs_manager_display_right_margin_can_set ());
gtk_widget_set_sensitive (dlg->priv->wrap_text_checkbutton, wrap_mode_can_set);
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, wrap_mode_can_set && (wrap_mode != GTK_WRAP_NONE));
gtk_widget_set_sensitive (dlg->priv->right_margin_checkbutton, xed_prefs_manager_display_right_margin_can_set ());
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox,
display_right_margin &&
xed_prefs_manager_right_margin_position_can_set ());
display_right_margin && xed_prefs_manager_right_margin_position_can_set ());
/* Connect signals */
g_signal_connect (dlg->priv->display_line_numbers_checkbutton,
"toggled",
G_CALLBACK (display_line_numbers_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->highlight_current_line_checkbutton,
"toggled",
G_CALLBACK (highlight_current_line_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->bracket_matching_checkbutton,
"toggled",
G_CALLBACK (bracket_matching_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->wrap_text_checkbutton,
"toggled",
G_CALLBACK (wrap_mode_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->split_checkbutton,
"toggled",
G_CALLBACK (wrap_mode_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->right_margin_checkbutton,
"toggled",
G_CALLBACK (right_margin_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->right_margin_position_spinbutton,
"value_changed",
G_CALLBACK (right_margin_position_spinbutton_value_changed),
dlg);
g_signal_connect (dlg->priv->display_line_numbers_checkbutton, "toggled",
G_CALLBACK (display_line_numbers_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->highlight_current_line_checkbutton, "toggled",
G_CALLBACK (highlight_current_line_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->bracket_matching_checkbutton, "toggled",
G_CALLBACK (bracket_matching_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->split_checkbutton, "toggled",
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->right_margin_checkbutton, "toggled",
G_CALLBACK (right_margin_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->right_margin_position_spinbutton, "value_changed",
G_CALLBACK (right_margin_position_spinbutton_value_changed), dlg);
}
static void
@ -532,8 +464,7 @@ default_font_font_checkbutton_toggled (GtkToggleButton *button,
}
else
{
gtk_widget_set_sensitive (dlg->priv->font_hbox,
xed_prefs_manager_editor_font_can_set ());
gtk_widget_set_sensitive (dlg->priv->font_hbox, xed_prefs_manager_editor_font_can_set ());
xed_prefs_manager_set_use_default_font (FALSE);
}
}
@ -579,45 +510,39 @@ setup_font_colors_page_font_section (XedPreferencesDialog *dlg)
ATK_RELATION_CONTROLLER_FOR);
editor_font = xed_prefs_manager_get_system_font ();
label = g_strdup_printf(_("_Use the system fixed width font (%s)"),
editor_font);
gtk_button_set_label (GTK_BUTTON (dlg->priv->default_font_checkbutton),
label);
label = g_strdup_printf(_("_Use the system fixed width font (%s)"), editor_font);
gtk_button_set_label (GTK_BUTTON (dlg->priv->default_font_checkbutton), label);
g_free (editor_font);
g_free (label);
/* read current config and setup initial state */
use_default_font = xed_prefs_manager_get_use_default_font ();
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton),
use_default_font);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton), use_default_font);
editor_font = xed_prefs_manager_get_editor_font ();
if (editor_font != NULL)
{
gtk_font_button_set_font_name (GTK_FONT_BUTTON (dlg->priv->font_button),
editor_font);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (dlg->priv->font_button), editor_font);
g_free (editor_font);
}
/* Connect signals */
g_signal_connect (dlg->priv->default_font_checkbutton,
"toggled",
G_CALLBACK (default_font_font_checkbutton_toggled),
dlg);
g_signal_connect (dlg->priv->font_button,
"font_set",
G_CALLBACK (editor_font_button_font_set),
dlg);
g_signal_connect (dlg->priv->default_font_checkbutton, "toggled",
G_CALLBACK (default_font_font_checkbutton_toggled), dlg);
g_signal_connect (dlg->priv->font_button, "font_set",
G_CALLBACK (editor_font_button_font_set), dlg);
/* Set initial widget sensitivity */
gtk_widget_set_sensitive (dlg->priv->default_font_checkbutton,
xed_prefs_manager_use_default_font_can_set ());
gtk_widget_set_sensitive (dlg->priv->default_font_checkbutton, xed_prefs_manager_use_default_font_can_set ());
if (use_default_font)
{
gtk_widget_set_sensitive (dlg->priv->font_hbox, FALSE);
}
else
gtk_widget_set_sensitive (dlg->priv->font_hbox,
xed_prefs_manager_editor_font_can_set ());
{
gtk_widget_set_sensitive (dlg->priv->font_hbox, xed_prefs_manager_editor_font_can_set ());
}
}
static void
@ -627,12 +552,9 @@ set_buttons_sensisitivity_according_to_scheme (XedPreferencesDialog *dlg,
gboolean editable;
editable = (scheme_id != NULL) &&
_xed_style_scheme_manager_scheme_is_xed_user_scheme (
xed_get_style_scheme_manager (),
scheme_id);
_xed_style_scheme_manager_scheme_is_xed_user_scheme (xed_get_style_scheme_manager (), scheme_id);
gtk_widget_set_sensitive (dlg->priv->uninstall_scheme_button,
editable);
gtk_widget_set_sensitive (dlg->priv->uninstall_scheme_button, editable);
}
static void
@ -644,11 +566,9 @@ style_scheme_changed (GtkWidget *treeview,
gchar *id;
gtk_tree_view_get_cursor (GTK_TREE_VIEW (dlg->priv->schemes_treeview), &path, NULL);
gtk_tree_model_get_iter (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model),
&iter, path);
gtk_tree_model_get_iter (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, path);
gtk_tree_path_free (path);
gtk_tree_model_get (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model),
&iter, ID_COLUMN, &id, -1);
gtk_tree_model_get (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, ID_COLUMN, &id, -1);
xed_prefs_manager_set_source_style_scheme (id);
@ -668,21 +588,18 @@ ensure_color_scheme_id (const gchar *id)
gchar *pref_id;
pref_id = xed_prefs_manager_get_source_style_scheme ();
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
pref_id);
scheme = gtk_source_style_scheme_manager_get_scheme (manager, pref_id);
g_free (pref_id);
}
else
{
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
id);
scheme = gtk_source_style_scheme_manager_get_scheme (manager, id);
}
if (scheme == NULL)
{
/* Fall-back to classic style scheme */
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
"classic");
scheme = gtk_source_style_scheme_manager_get_scheme (manager, "classic");
}
if (scheme == NULL)
@ -698,7 +615,8 @@ ensure_color_scheme_id (const gchar *id)
* xed_style_scheme_manager_get_default_scheme. If this one returns NULL
* use the first available scheme as default */
static const gchar *
populate_color_scheme_list (XedPreferencesDialog *dlg, const gchar *def_id)
populate_color_scheme_list (XedPreferencesDialog *dlg,
const gchar *def_id)
{
GSList *schemes;
GSList *l;
@ -774,16 +692,12 @@ add_scheme_chooser_response_cb (GtkDialog *chooser,
gtk_widget_hide (GTK_WIDGET (chooser));
scheme_id = _xed_style_scheme_manager_install_scheme (
xed_get_style_scheme_manager (),
filename);
scheme_id = _xed_style_scheme_manager_install_scheme (xed_get_style_scheme_manager (), filename);
g_free (filename);
if (scheme_id == NULL)
{
xed_warning (GTK_WINDOW (dlg),
_("The selected color scheme cannot be installed."));
xed_warning (GTK_WINDOW (dlg), _("The selected color scheme cannot be installed."));
return;
}
@ -801,7 +715,8 @@ install_scheme_clicked (GtkButton *button,
GtkWidget *chooser;
GtkFileFilter *filter;
if (dlg->priv->install_scheme_file_schooser != NULL) {
if (dlg->priv->install_scheme_file_schooser != NULL)
{
gtk_window_present (GTK_WINDOW (dlg->priv->install_scheme_file_schooser));
gtk_widget_grab_focus (dlg->priv->install_scheme_file_schooser);
return;
@ -813,10 +728,8 @@ install_scheme_clicked (GtkButton *button,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
xed_dialog_add_button (GTK_DIALOG (chooser),
_("A_dd Scheme"),
GTK_STOCK_ADD,
GTK_RESPONSE_ACCEPT);
xed_dialog_add_button (GTK_DIALOG (chooser), _("A_dd Scheme"),
GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT);
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
@ -835,15 +748,12 @@ install_scheme_clicked (GtkButton *button,
gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
g_signal_connect (chooser,
"response",
G_CALLBACK (add_scheme_chooser_response_cb),
dlg);
g_signal_connect (chooser, "response",
G_CALLBACK (add_scheme_chooser_response_cb), dlg);
dlg->priv->install_scheme_file_schooser = chooser;
g_object_add_weak_pointer (G_OBJECT (chooser),
(gpointer) &dlg->priv->install_scheme_file_schooser);
g_object_add_weak_pointer (G_OBJECT (chooser), (gpointer) &dlg->priv->install_scheme_file_schooser);
gtk_widget_show (chooser);
}
@ -859,23 +769,16 @@ uninstall_scheme_clicked (GtkButton *button,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
model = GTK_TREE_MODEL (dlg->priv->schemes_treeview_model);
if (gtk_tree_selection_get_selected (selection,
&model,
&iter))
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gchar *id;
gchar *name;
gtk_tree_model_get (model, &iter,
ID_COLUMN, &id,
NAME_COLUMN, &name,
-1);
gtk_tree_model_get (model, &iter, ID_COLUMN, &id, NAME_COLUMN, &name, -1);
if (!_xed_style_scheme_manager_uninstall_scheme (xed_get_style_scheme_manager (), id))
{
xed_warning (GTK_WINDOW (dlg),
_("Could not remove color scheme \"%s\"."),
name);
xed_warning (GTK_WINDOW (dlg), _("Could not remove color scheme \"%s\"."), name);
}
else
{
@ -908,17 +811,21 @@ uninstall_scheme_clicked (GtkButton *button,
gtk_tree_path_prev (path);
if (gtk_tree_model_get_iter (model, &new_iter, path))
{
new_iter_set = TRUE;
}
}
else
{
new_iter_set = TRUE;
}
gtk_tree_path_free (path);
if (new_iter_set)
gtk_tree_model_get (model, &new_iter,
ID_COLUMN, &new_id,
-1);
{
gtk_tree_model_get (model, &new_iter, ID_COLUMN, &new_id, -1);
}
real_new_id = populate_color_scheme_list (dlg, new_id);
g_free (new_id);
@ -926,8 +833,10 @@ uninstall_scheme_clicked (GtkButton *button,
set_buttons_sensisitivity_according_to_scheme (dlg, real_new_id);
if (real_new_id != NULL)
{
xed_prefs_manager_set_source_style_scheme (real_new_id);
}
}
g_free (id);
g_free (name);
@ -945,30 +854,21 @@ scheme_description_cell_data_func (GtkTreeViewColumn *column,
gchar *desc;
gchar *text;
gtk_tree_model_get (model, iter,
NAME_COLUMN, &name,
DESC_COLUMN, &desc,
-1);
gtk_tree_model_get (model, iter, NAME_COLUMN, &name, DESC_COLUMN, &desc, -1);
if (desc != NULL)
{
text = g_markup_printf_escaped ("<b>%s</b> - %s",
name,
desc);
text = g_markup_printf_escaped ("<b>%s</b> - %s", name, desc);
}
else
{
text = g_markup_printf_escaped ("<b>%s</b>",
name);
text = g_markup_printf_escaped ("<b>%s</b>", name);
}
g_free (name);
g_free (desc);
g_object_set (G_OBJECT (renderer),
"markup",
text,
NULL);
g_object_set (G_OBJECT (renderer), "markup", text, NULL);
g_free (text);
}
@ -991,8 +891,7 @@ setup_font_colors_page_style_scheme_section (XedPreferencesDialog *dlg)
G_TYPE_STRING);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dlg->priv->schemes_treeview_model),
0,
GTK_SORT_ASCENDING);
0, GTK_SORT_ASCENDING);
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->schemes_treeview),
GTK_TREE_MODEL (dlg->priv->schemes_treeview_model));
@ -1007,8 +906,7 @@ setup_font_colors_page_style_scheme_section (XedPreferencesDialog *dlg)
dlg,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->schemes_treeview),
column);
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->schemes_treeview), column);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
@ -1016,18 +914,12 @@ setup_font_colors_page_style_scheme_section (XedPreferencesDialog *dlg)
def_id = populate_color_scheme_list (dlg, NULL);
/* Connect signals */
g_signal_connect (dlg->priv->schemes_treeview,
"cursor-changed",
G_CALLBACK (style_scheme_changed),
dlg);
g_signal_connect (dlg->priv->install_scheme_button,
"clicked",
G_CALLBACK (install_scheme_clicked),
dlg);
g_signal_connect (dlg->priv->uninstall_scheme_button,
"clicked",
G_CALLBACK (uninstall_scheme_clicked),
dlg);
g_signal_connect (dlg->priv->schemes_treeview, "cursor-changed",
G_CALLBACK (style_scheme_changed), dlg);
g_signal_connect (dlg->priv->install_scheme_button, "clicked",
G_CALLBACK (install_scheme_clicked), dlg);
g_signal_connect (dlg->priv->uninstall_scheme_button, "clicked",
G_CALLBACK (uninstall_scheme_clicked), dlg);
/* Set initial widget sensitivity */
set_buttons_sensisitivity_according_to_scheme (dlg, def_id);
@ -1050,11 +942,7 @@ setup_plugins_page (XedPreferencesDialog *dlg)
page_content = peas_gtk_plugin_manager_new (NULL);
g_return_if_fail (page_content != NULL);
gtk_box_pack_start (GTK_BOX (dlg->priv->plugin_manager_place_holder),
page_content,
TRUE,
TRUE,
0);
gtk_box_pack_start (GTK_BOX (dlg->priv->plugin_manager_place_holder), page_content, TRUE, TRUE, 0);
gtk_widget_show_all (page_content);
}
@ -1079,10 +967,8 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
dlg->priv = XED_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
NULL);
gtk_window_set_title (GTK_WINDOW (dlg), _("Xed Preferences"));
@ -1095,16 +981,11 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 6);
g_signal_connect (dlg,
"response",
G_CALLBACK (dialog_response_handler),
NULL);
g_signal_connect (dlg, "response",
G_CALLBACK (dialog_response_handler), NULL);
file = xed_dirs_get_ui_file ("xed-preferences-dialog.ui");
ret = xed_utils_get_ui_objects (file,
root_objects,
&error_widget,
ret = xed_utils_get_ui_objects (file, root_objects, &error_widget,
"notebook", &dlg->priv->notebook,
"display_line_numbers_checkbutton", &dlg->priv->display_line_numbers_checkbutton,
@ -1144,16 +1025,11 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
if (!ret)
{
gtk_widget_show (error_widget);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
error_widget,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), error_widget, TRUE, TRUE, 0);
return;
}
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
dlg->priv->notebook, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), dlg->priv->notebook, FALSE, FALSE, 0);
g_object_unref (dlg->priv->notebook);
gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
@ -1173,16 +1049,13 @@ xed_show_preferences_dialog (XedWindow *parent)
if (preferences_dialog == NULL)
{
preferences_dialog = GTK_WIDGET (g_object_new (XED_TYPE_PREFERENCES_DIALOG, NULL));
g_signal_connect (preferences_dialog,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
&preferences_dialog);
g_signal_connect (preferences_dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed), &preferences_dialog);
}
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (preferences_dialog)))
{
gtk_window_set_transient_for (GTK_WINDOW (preferences_dialog),
GTK_WINDOW (parent));
gtk_window_set_transient_for (GTK_WINDOW (preferences_dialog), GTK_WINDOW (parent));
}
gtk_window_present (GTK_WINDOW (preferences_dialog));