Add ui_radio_menu_item_set_active_index(),

ui_radio_menu_item_get_active_index().


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/custom-tab-width@2831 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-07-28 17:28:19 +00:00
parent da4a914d5e
commit 5dc0ae673b
3 changed files with 49 additions and 1 deletions

View File

@ -14,6 +14,9 @@
* src/prefs.c:
Add spin_items_foreach().
Bind spin_indent_width, spin_tab_width widgets to settings.
* src/ui_utils.c, src/ui_utils.h:
Add ui_radio_menu_item_set_active_index(),
ui_radio_menu_item_get_active_index().
2008-07-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -706,7 +706,8 @@ void ui_document_show_hide(GeanyDocument *doc)
item = lookup_widget(main_widgets.window, "menu_use_auto_indentation1");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), doc->editor->auto_indent);
gtk_widget_set_sensitive(item, editor_prefs.indent_mode != INDENT_NONE);
gtk_widget_set_sensitive(item,
editor_prefs.indentation->auto_indent_mode != GEANY_AUTOINDENT_NONE);
item = lookup_widget(main_widgets.window, doc->editor->use_tabs ? "tabs1" : "spaces1");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
@ -1505,3 +1506,43 @@ void ui_init(void)
init_document_widgets();
}
void ui_radio_menu_item_set_active_index(GtkRadioMenuItem *widget, guint idx)
{
GSList *item = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(widget));
guint i;
for (i = 0; item != NULL; item = g_slist_next(item), i++)
{
if (i == idx)
{
GtkCheckMenuItem *radio = item->data;
gtk_check_menu_item_set_active(radio, TRUE);
return;
}
}
g_warning("Index %u is out of range for group of widget %s",
idx, gtk_widget_get_name(GTK_WIDGET(widget)));
}
guint ui_radio_menu_item_get_active_index(GtkRadioMenuItem *widget)
{
GSList *item = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(widget));
guint i;
for (i = 0; item != NULL; item = g_slist_next(item), i++)
{
GtkCheckMenuItem *radio = item->data;
if (gtk_check_menu_item_get_active(radio))
return i;
}
g_warning("No active group item for widget %s",
gtk_widget_get_name(GTK_WIDGET(widget)));
return 0;
}

View File

@ -151,6 +151,10 @@ void ui_setup_open_button_callback(GtkWidget *open_btn, const gchar *title,
void ui_table_add_row(GtkTable *table, gint row, ...) G_GNUC_NULL_TERMINATED;
void ui_radio_menu_item_set_active_index(GtkRadioMenuItem *widget, guint index);
guint ui_radio_menu_item_get_active_index(GtkRadioMenuItem *widget);
/* End of 'generic' functions */