SF.net SVN: geany:[2831] branches/custom-tab-width

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Jul 28 17:28:19 UTC 2008


Revision: 2831
          http://geany.svn.sourceforge.net/geany/?rev=2831&view=rev
Author:   ntrel
Date:     2008-07-28 17:28:19 +0000 (Mon, 28 Jul 2008)

Log Message:
-----------
Add ui_radio_menu_item_set_active_index(),
ui_radio_menu_item_get_active_index().

Modified Paths:
--------------
    branches/custom-tab-width/ChangeLog
    branches/custom-tab-width/src/ui_utils.c
    branches/custom-tab-width/src/ui_utils.h

Modified: branches/custom-tab-width/ChangeLog
===================================================================
--- branches/custom-tab-width/ChangeLog	2008-07-28 13:50:55 UTC (rev 2830)
+++ branches/custom-tab-width/ChangeLog	2008-07-28 17:28:19 UTC (rev 2831)
@@ -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>

Modified: branches/custom-tab-width/src/ui_utils.c
===================================================================
--- branches/custom-tab-width/src/ui_utils.c	2008-07-28 13:50:55 UTC (rev 2830)
+++ branches/custom-tab-width/src/ui_utils.c	2008-07-28 17:28:19 UTC (rev 2831)
@@ -706,7 +706,8 @@
 
 	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 @@
 
 	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;
+}
+
+

Modified: branches/custom-tab-width/src/ui_utils.h
===================================================================
--- branches/custom-tab-width/src/ui_utils.h	2008-07-28 13:50:55 UTC (rev 2830)
+++ branches/custom-tab-width/src/ui_utils.h	2008-07-28 17:28:19 UTC (rev 2831)
@@ -151,6 +151,10 @@
 
 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 */
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list