xed-highlight-mode-dialog/selector: Clean up code style

Fix a few indentation errors and convert tabs to spaces.
This commit is contained in:
JosephMcc 2020-09-08 22:53:25 -07:00 committed by Michael Webster
parent 33d035aac7
commit 3bf1b62a34
2 changed files with 256 additions and 260 deletions

View File

@ -24,40 +24,40 @@
struct _XedHighlightModeDialog struct _XedHighlightModeDialog
{ {
GtkDialog parent_instance; GtkDialog parent_instance;
XedHighlightModeSelector *selector; XedHighlightModeSelector *selector;
gulong on_language_selected_id; gulong on_language_selected_id;
}; };
G_DEFINE_TYPE (XedHighlightModeDialog, xed_highlight_mode_dialog, GTK_TYPE_DIALOG) G_DEFINE_TYPE (XedHighlightModeDialog, xed_highlight_mode_dialog, GTK_TYPE_DIALOG)
static void static void
xed_highlight_mode_dialog_response (GtkDialog *dialog, xed_highlight_mode_dialog_response (GtkDialog *dialog,
gint response_id) gint response_id)
{ {
XedHighlightModeDialog *dlg = XED_HIGHLIGHT_MODE_DIALOG (dialog); XedHighlightModeDialog *dlg = XED_HIGHLIGHT_MODE_DIALOG (dialog);
if (response_id == GTK_RESPONSE_OK) if (response_id == GTK_RESPONSE_OK)
{ {
g_signal_handler_block (dlg->selector, dlg->on_language_selected_id); g_signal_handler_block (dlg->selector, dlg->on_language_selected_id);
xed_highlight_mode_selector_activate_selected_language (dlg->selector); xed_highlight_mode_selector_activate_selected_language (dlg->selector);
g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id); g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id);
} }
gtk_widget_destroy (GTK_WIDGET (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog));
} }
static void static void
on_language_selected (XedHighlightModeSelector *sel, on_language_selected (XedHighlightModeSelector *sel,
GtkSourceLanguage *language, GtkSourceLanguage *language,
XedHighlightModeDialog *dlg) XedHighlightModeDialog *dlg)
{ {
g_signal_handler_block (dlg->selector, dlg->on_language_selected_id); g_signal_handler_block (dlg->selector, dlg->on_language_selected_id);
xed_highlight_mode_selector_activate_selected_language (dlg->selector); xed_highlight_mode_selector_activate_selected_language (dlg->selector);
g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id); g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id);
gtk_widget_destroy (GTK_WIDGET (dlg)); gtk_widget_destroy (GTK_WIDGET (dlg));
} }
static void static void
@ -70,25 +70,25 @@ on_dialog_cancelled (XedHighlightModeSelector *sel,
static void static void
xed_highlight_mode_dialog_class_init (XedHighlightModeDialogClass *klass) xed_highlight_mode_dialog_class_init (XedHighlightModeDialogClass *klass)
{ {
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass); GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
dialog_class->response = xed_highlight_mode_dialog_response; dialog_class->response = xed_highlight_mode_dialog_response;
/* Bind class to template */ /* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class, gtk_widget_class_set_template_from_resource (widget_class,
"/org/x/editor/ui/xed-highlight-mode-dialog.ui"); "/org/x/editor/ui/xed-highlight-mode-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeDialog, selector); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeDialog, selector);
} }
static void static void
xed_highlight_mode_dialog_init (XedHighlightModeDialog *dlg) xed_highlight_mode_dialog_init (XedHighlightModeDialog *dlg)
{ {
gtk_widget_init_template (GTK_WIDGET (dlg)); gtk_widget_init_template (GTK_WIDGET (dlg));
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
dlg->on_language_selected_id = g_signal_connect (dlg->selector, "language-selected", dlg->on_language_selected_id = g_signal_connect (dlg->selector, "language-selected",
G_CALLBACK (on_language_selected), dlg); G_CALLBACK (on_language_selected), dlg);
g_signal_connect (dlg->selector, "cancelled", g_signal_connect (dlg->selector, "cancelled",
G_CALLBACK (on_dialog_cancelled), dlg); G_CALLBACK (on_dialog_cancelled), dlg);
@ -97,17 +97,15 @@ xed_highlight_mode_dialog_init (XedHighlightModeDialog *dlg)
GtkWidget * GtkWidget *
xed_highlight_mode_dialog_new (GtkWindow *parent) xed_highlight_mode_dialog_new (GtkWindow *parent)
{ {
return GTK_WIDGET (g_object_new (XED_TYPE_HIGHLIGHT_MODE_DIALOG, return GTK_WIDGET (g_object_new (XED_TYPE_HIGHLIGHT_MODE_DIALOG,
"transient-for", parent, "transient-for", parent,
NULL)); NULL));
} }
XedHighlightModeSelector * XedHighlightModeSelector *
xed_highlight_mode_dialog_get_selector (XedHighlightModeDialog *dlg) xed_highlight_mode_dialog_get_selector (XedHighlightModeDialog *dlg)
{ {
g_return_val_if_fail (XED_IS_HIGHLIGHT_MODE_DIALOG (dlg), NULL); g_return_val_if_fail (XED_IS_HIGHLIGHT_MODE_DIALOG (dlg), NULL);
return dlg->selector; return dlg->selector;
} }
/* ex:set ts=8 noet: */

View File

@ -26,28 +26,28 @@
enum enum
{ {
COLUMN_NAME, COLUMN_NAME,
COLUMN_LANG, COLUMN_LANG,
N_COLUMNS N_COLUMNS
}; };
struct _XedHighlightModeSelector struct _XedHighlightModeSelector
{ {
GtkGrid parent_instance; GtkGrid parent_instance;
GtkWidget *treeview; GtkWidget *treeview;
GtkWidget *entry; GtkWidget *entry;
GtkListStore *liststore; GtkListStore *liststore;
GtkTreeModelFilter *treemodelfilter; GtkTreeModelFilter *treemodelfilter;
GtkTreeSelection *treeview_selection; GtkTreeSelection *treeview_selection;
}; };
/* Signals */ /* Signals */
enum enum
{ {
LANGUAGE_SELECTED, LANGUAGE_SELECTED,
CANCELLED, CANCELLED,
LAST_SIGNAL LAST_SIGNAL
}; };
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
@ -56,24 +56,24 @@ G_DEFINE_TYPE (XedHighlightModeSelector, xed_highlight_mode_selector, GTK_TYPE_G
static void static void
xed_highlight_mode_selector_language_selected (XedHighlightModeSelector *widget, xed_highlight_mode_selector_language_selected (XedHighlightModeSelector *widget,
GtkSourceLanguage *language) GtkSourceLanguage *language)
{ {
} }
static void static void
xed_highlight_mode_selector_class_init (XedHighlightModeSelectorClass *klass) xed_highlight_mode_selector_class_init (XedHighlightModeSelectorClass *klass)
{ {
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
signals[LANGUAGE_SELECTED] = signals[LANGUAGE_SELECTED] =
g_signal_new_class_handler ("language-selected", g_signal_new_class_handler ("language-selected",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (xed_highlight_mode_selector_language_selected), G_CALLBACK (xed_highlight_mode_selector_language_selected),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, G_TYPE_NONE,
1, 1,
GTK_SOURCE_TYPE_LANGUAGE); GTK_SOURCE_TYPE_LANGUAGE);
signals[CANCELLED] = signals[CANCELLED] =
g_signal_new_class_handler ("cancelled", g_signal_new_class_handler ("cancelled",
@ -82,162 +82,162 @@ xed_highlight_mode_selector_class_init (XedHighlightModeSelectorClass *klass)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/* Bind class to template */ /* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class, gtk_widget_class_set_template_from_resource (widget_class,
"/org/x/editor/ui/xed-highlight-mode-selector.ui"); "/org/x/editor/ui/xed-highlight-mode-selector.ui");
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treeview); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treeview);
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, entry); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, entry);
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, liststore); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, liststore);
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treemodelfilter); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treemodelfilter);
gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treeview_selection); gtk_widget_class_bind_template_child (widget_class, XedHighlightModeSelector, treeview_selection);
} }
static gboolean static gboolean
visible_func (GtkTreeModel *model, visible_func (GtkTreeModel *model,
GtkTreeIter *iter, GtkTreeIter *iter,
XedHighlightModeSelector *selector) XedHighlightModeSelector *selector)
{ {
const gchar *entry_text; const gchar *entry_text;
gchar *name; gchar *name;
gchar *name_normalized; gchar *name_normalized;
gchar *name_casefolded; gchar *name_casefolded;
gchar *text_normalized; gchar *text_normalized;
gchar *text_casefolded; gchar *text_casefolded;
gboolean visible = FALSE; gboolean visible = FALSE;
entry_text = gtk_entry_get_text (GTK_ENTRY (selector->entry)); entry_text = gtk_entry_get_text (GTK_ENTRY (selector->entry));
if (*entry_text == '\0') if (*entry_text == '\0')
{ {
return TRUE; return TRUE;
} }
gtk_tree_model_get (model, iter, COLUMN_NAME, &name, -1); gtk_tree_model_get (model, iter, COLUMN_NAME, &name, -1);
name_normalized = g_utf8_normalize (name, -1, G_NORMALIZE_ALL); name_normalized = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
g_free (name); g_free (name);
name_casefolded = g_utf8_casefold (name_normalized, -1); name_casefolded = g_utf8_casefold (name_normalized, -1);
g_free (name_normalized); g_free (name_normalized);
text_normalized = g_utf8_normalize (entry_text, -1, G_NORMALIZE_ALL); text_normalized = g_utf8_normalize (entry_text, -1, G_NORMALIZE_ALL);
text_casefolded = g_utf8_casefold (text_normalized, -1); text_casefolded = g_utf8_casefold (text_normalized, -1);
g_free (text_normalized); g_free (text_normalized);
if (strstr (name_casefolded, text_casefolded) != NULL) if (strstr (name_casefolded, text_casefolded) != NULL)
{ {
visible = TRUE; visible = TRUE;
} }
g_free (name_casefolded); g_free (name_casefolded);
g_free (text_casefolded); g_free (text_casefolded);
return visible; return visible;
} }
static void static void
on_entry_activate (GtkEntry *entry, on_entry_activate (GtkEntry *entry,
XedHighlightModeSelector *selector) XedHighlightModeSelector *selector)
{ {
xed_highlight_mode_selector_activate_selected_language (selector); xed_highlight_mode_selector_activate_selected_language (selector);
} }
static void static void
on_entry_changed (GtkEntry *entry, on_entry_changed (GtkEntry *entry,
XedHighlightModeSelector *selector) XedHighlightModeSelector *selector)
{ {
GtkTreeIter iter; GtkTreeIter iter;
gtk_tree_model_filter_refilter (selector->treemodelfilter); gtk_tree_model_filter_refilter (selector->treemodelfilter);
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter)) if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
{ {
gtk_tree_selection_select_iter (selector->treeview_selection, &iter); gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
} }
} }
static gboolean static gboolean
move_selection (XedHighlightModeSelector *selector, move_selection (XedHighlightModeSelector *selector,
gint howmany) gint howmany)
{ {
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path; GtkTreePath *path;
gint *indices; gint *indices;
gint ret = FALSE; gint ret = FALSE;
if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter) && if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter) &&
!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter)) !gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
{ {
return FALSE; return FALSE;
} }
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter); path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter);
indices = gtk_tree_path_get_indices (path); indices = gtk_tree_path_get_indices (path);
if (indices) if (indices)
{ {
gint num; gint num;
gint idx; gint idx;
GtkTreePath *new_path; GtkTreePath *new_path;
idx = indices[0]; idx = indices[0];
num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (selector->treemodelfilter), NULL); num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (selector->treemodelfilter), NULL);
if ((idx + howmany) < 0) if ((idx + howmany) < 0)
{ {
idx = 0; idx = 0;
} }
else if ((idx + howmany) >= num) else if ((idx + howmany) >= num)
{ {
idx = num - 1; idx = num - 1;
} }
else else
{ {
idx = idx + howmany; idx = idx + howmany;
} }
new_path = gtk_tree_path_new_from_indices (idx, -1); new_path = gtk_tree_path_new_from_indices (idx, -1);
gtk_tree_selection_select_path (selector->treeview_selection, new_path); gtk_tree_selection_select_path (selector->treeview_selection, new_path);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview), gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview),
new_path, NULL, TRUE, 0.5, 0); new_path, NULL, TRUE, 0.5, 0);
gtk_tree_path_free (new_path); gtk_tree_path_free (new_path);
ret = TRUE; ret = TRUE;
} }
gtk_tree_path_free (path); gtk_tree_path_free (path);
return ret; return ret;
} }
static gboolean static gboolean
on_entry_key_press_event (GtkWidget *entry, on_entry_key_press_event (GtkWidget *entry,
GdkEventKey *event, GdkEventKey *event,
XedHighlightModeSelector *selector) XedHighlightModeSelector *selector)
{ {
if (event->keyval == GDK_KEY_Down) if (event->keyval == GDK_KEY_Down)
{ {
return move_selection (selector, 1); return move_selection (selector, 1);
} }
else if (event->keyval == GDK_KEY_Up) else if (event->keyval == GDK_KEY_Up)
{ {
return move_selection (selector, -1); return move_selection (selector, -1);
} }
else if (event->keyval == GDK_KEY_Page_Down) else if (event->keyval == GDK_KEY_Page_Down)
{ {
return move_selection (selector, 5); return move_selection (selector, 5);
} }
else if (event->keyval == GDK_KEY_Page_Up) else if (event->keyval == GDK_KEY_Page_Up)
{ {
return move_selection (selector, -5); return move_selection (selector, -5);
} }
else if (event->keyval == GDK_KEY_Escape) else if (event->keyval == GDK_KEY_Escape)
{ {
g_signal_emit (G_OBJECT (selector), signals[CANCELLED], 0); g_signal_emit (G_OBJECT (selector), signals[CANCELLED], 0);
return FALSE; return FALSE;
} }
return FALSE; return FALSE;
} }
static void static void
@ -255,152 +255,150 @@ on_entry_realized (GtkWidget *entry,
} }
static void static void
on_row_activated (GtkTreeView *tree_view, on_row_activated (GtkTreeView *tree_view,
GtkTreePath *path, GtkTreePath *path,
GtkTreeViewColumn *column, GtkTreeViewColumn *column,
XedHighlightModeSelector *selector) XedHighlightModeSelector *selector)
{ {
xed_highlight_mode_selector_activate_selected_language (selector); xed_highlight_mode_selector_activate_selected_language (selector);
} }
static void static void
xed_highlight_mode_selector_init (XedHighlightModeSelector *selector) xed_highlight_mode_selector_init (XedHighlightModeSelector *selector)
{ {
GtkSourceLanguageManager *lm; GtkSourceLanguageManager *lm;
const gchar * const *ids; const gchar * const *ids;
gint i; gint i;
GtkTreeIter iter; GtkTreeIter iter;
selector = xed_highlight_mode_selector_get_instance_private (selector); selector = xed_highlight_mode_selector_get_instance_private (selector);
gtk_widget_init_template (GTK_WIDGET (selector)); gtk_widget_init_template (GTK_WIDGET (selector));
gtk_tree_model_filter_set_visible_func (selector->treemodelfilter, gtk_tree_model_filter_set_visible_func (selector->treemodelfilter,
(GtkTreeModelFilterVisibleFunc)visible_func, (GtkTreeModelFilterVisibleFunc)visible_func,
selector, selector,
NULL); NULL);
g_signal_connect (selector->entry, "activate", g_signal_connect (selector->entry, "activate",
G_CALLBACK (on_entry_activate), selector); G_CALLBACK (on_entry_activate), selector);
g_signal_connect (selector->entry, "changed", g_signal_connect (selector->entry, "changed",
G_CALLBACK (on_entry_changed), selector); G_CALLBACK (on_entry_changed), selector);
g_signal_connect (selector->entry, "key-press-event", g_signal_connect (selector->entry, "key-press-event",
G_CALLBACK (on_entry_key_press_event), selector); G_CALLBACK (on_entry_key_press_event), selector);
g_signal_connect (selector->entry, "realize", g_signal_connect (selector->entry, "realize",
G_CALLBACK (on_entry_realized), selector); G_CALLBACK (on_entry_realized), selector);
g_signal_connect (selector->treeview, "row-activated", g_signal_connect (selector->treeview, "row-activated",
G_CALLBACK (on_row_activated), selector); G_CALLBACK (on_row_activated), selector);
/* Populate tree model */ /* Populate tree model */
gtk_list_store_append (selector->liststore, &iter); gtk_list_store_append (selector->liststore, &iter);
gtk_list_store_set (selector->liststore, &iter, gtk_list_store_set (selector->liststore, &iter,
COLUMN_NAME, _("Plain Text"), COLUMN_NAME, _("Plain Text"),
COLUMN_LANG, NULL, COLUMN_LANG, NULL,
-1); -1);
lm = gtk_source_language_manager_get_default (); lm = gtk_source_language_manager_get_default ();
ids = gtk_source_language_manager_get_language_ids (lm); ids = gtk_source_language_manager_get_language_ids (lm);
for (i = 0; ids[i] != NULL; i++) for (i = 0; ids[i] != NULL; i++)
{ {
GtkSourceLanguage *lang; GtkSourceLanguage *lang;
lang = gtk_source_language_manager_get_language (lm, ids[i]); lang = gtk_source_language_manager_get_language (lm, ids[i]);
if (!gtk_source_language_get_hidden (lang)) if (!gtk_source_language_get_hidden (lang))
{ {
gtk_list_store_append (selector->liststore, &iter); gtk_list_store_append (selector->liststore, &iter);
gtk_list_store_set (selector->liststore, &iter, gtk_list_store_set (selector->liststore, &iter,
COLUMN_NAME, gtk_source_language_get_name (lang), COLUMN_NAME, gtk_source_language_get_name (lang),
COLUMN_LANG, lang, COLUMN_LANG, lang,
-1); -1);
} }
} }
/* select first item */ /* select first item */
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter)) if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
{ {
gtk_tree_selection_select_iter (selector->treeview_selection, &iter); gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
} }
} }
XedHighlightModeSelector * XedHighlightModeSelector *
xed_highlight_mode_selector_new () xed_highlight_mode_selector_new ()
{ {
return g_object_new (XED_TYPE_HIGHLIGHT_MODE_SELECTOR, NULL); return g_object_new (XED_TYPE_HIGHLIGHT_MODE_SELECTOR, NULL);
} }
void void
xed_highlight_mode_selector_select_language (XedHighlightModeSelector *selector, xed_highlight_mode_selector_select_language (XedHighlightModeSelector *selector,
GtkSourceLanguage *language) GtkSourceLanguage *language)
{ {
GtkTreeIter iter; GtkTreeIter iter;
g_return_if_fail (XED_IS_HIGHLIGHT_MODE_SELECTOR (selector)); g_return_if_fail (XED_IS_HIGHLIGHT_MODE_SELECTOR (selector));
if (language == NULL) if (language == NULL)
{ {
return; return;
} }
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter)) if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
{ {
do do
{ {
GtkSourceLanguage *lang; GtkSourceLanguage *lang;
gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter), gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter),
&iter, &iter,
COLUMN_LANG, &lang, COLUMN_LANG, &lang,
-1); -1);
if (lang != NULL) if (lang != NULL)
{ {
gboolean equal = (lang == language); gboolean equal = (lang == language);
g_object_unref (lang); g_object_unref (lang);
if (equal) if (equal)
{ {
GtkTreePath *path; GtkTreePath *path;
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter); path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter);
gtk_tree_selection_select_iter (selector->treeview_selection, &iter); gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview), gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview),
path, NULL, TRUE, 0.5, 0); path, NULL, TRUE, 0.5, 0);
gtk_tree_path_free (path); gtk_tree_path_free (path);
break; break;
} }
} }
} }
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (selector->treemodelfilter), &iter)); while (gtk_tree_model_iter_next (GTK_TREE_MODEL (selector->treemodelfilter), &iter));
} }
} }
void void
xed_highlight_mode_selector_activate_selected_language (XedHighlightModeSelector *selector) xed_highlight_mode_selector_activate_selected_language (XedHighlightModeSelector *selector)
{ {
GtkSourceLanguage *lang; GtkSourceLanguage *lang;
GtkTreeIter iter; GtkTreeIter iter;
g_return_if_fail (XED_IS_HIGHLIGHT_MODE_SELECTOR (selector)); g_return_if_fail (XED_IS_HIGHLIGHT_MODE_SELECTOR (selector));
if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter)) if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter))
{ {
return; return;
} }
gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter), &iter, gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter), &iter,
COLUMN_LANG, &lang, COLUMN_LANG, &lang,
-1); -1);
g_signal_emit (G_OBJECT (selector), signals[LANGUAGE_SELECTED], 0, lang); g_signal_emit (G_OBJECT (selector), signals[LANGUAGE_SELECTED], 0, lang);
if (lang != NULL) if (lang != NULL)
{ {
g_object_unref (lang); g_object_unref (lang);
} }
} }
/* ex:set ts=8 noet: */