xed-window: Indicate if we are currently using spaces or tabs in statusbar (#246)
Other editors like Sublime do this and it's more obvious to the user what they are currently using. The current label "Tab Width" can be misleading. Especially since we default to using spaces.
This commit is contained in:
parent
d99074ec5e
commit
494a2e7ce3
|
@ -1587,16 +1587,34 @@ tab_width_combo_changed (XedStatusComboBox *combo,
|
|||
g_signal_handler_unblock (view, window->priv->tab_width_id);
|
||||
}
|
||||
|
||||
static void
|
||||
set_tab_spaces_label (XedWindow *window,
|
||||
gboolean use_spaces)
|
||||
{
|
||||
if (use_spaces)
|
||||
{
|
||||
xed_status_combo_box_set_label (window->priv->tab_width_combo, _("Spaces"));
|
||||
}
|
||||
else
|
||||
{
|
||||
xed_status_combo_box_set_label (window->priv->tab_width_combo, _("Tabs"));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
use_spaces_toggled (GtkCheckMenuItem *item,
|
||||
XedWindow *window)
|
||||
{
|
||||
XedView *view;
|
||||
gboolean use_spaces;
|
||||
|
||||
view = xed_window_get_active_view (window);
|
||||
use_spaces = gtk_check_menu_item_get_active (item);
|
||||
|
||||
set_tab_spaces_label (window, use_spaces);
|
||||
|
||||
g_signal_handler_block (view, window->priv->spaces_instead_of_tabs_id);
|
||||
gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW(view), gtk_check_menu_item_get_active (item));
|
||||
gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view), use_spaces);
|
||||
g_signal_handler_unblock (view, window->priv->spaces_instead_of_tabs_id);
|
||||
}
|
||||
|
||||
|
@ -1637,6 +1655,7 @@ fill_tab_width_combo (XedWindow *window)
|
|||
XedStatusComboBox *combo = XED_STATUS_COMBO_BOX (window->priv->tab_width_combo);
|
||||
guint i = 0;
|
||||
GtkWidget *item;
|
||||
gboolean use_spaces;
|
||||
|
||||
while (defs[i].label != NULL)
|
||||
{
|
||||
|
@ -1662,6 +1681,9 @@ fill_tab_width_combo (XedWindow *window)
|
|||
gtk_widget_show (item);
|
||||
|
||||
g_signal_connect(item, "toggled", G_CALLBACK (use_spaces_toggled), window);
|
||||
|
||||
use_spaces = g_settings_get_boolean (window->priv->editor_settings, "insert-spaces");
|
||||
set_tab_spaces_label (window, use_spaces);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1726,7 +1748,7 @@ create_statusbar (XedWindow *window,
|
|||
gtk_widget_set_margin_start (GTK_WIDGET (window->priv->statusbar), 0);
|
||||
gtk_widget_set_margin_end (GTK_WIDGET (window->priv->statusbar), 0);
|
||||
|
||||
window->priv->tab_width_combo = xed_status_combo_box_new (_("Tab Width"));
|
||||
window->priv->tab_width_combo = xed_status_combo_box_new (NULL);
|
||||
gtk_widget_show (window->priv->tab_width_combo);
|
||||
gtk_box_pack_end (GTK_BOX (window->priv->statusbar), window->priv->tab_width_combo, FALSE, FALSE, 0);
|
||||
gtk_widget_set_margin_bottom (GTK_WIDGET (window->priv->tab_width_combo), 2);
|
||||
|
|
Loading…
Reference in New Issue