? wrap_mode-119428.patch
Index: gedit-mdi.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-mdi.c,v
retrieving revision 1.83
diff -u -p -r1.83 gedit-mdi.c
--- gedit-mdi.c	16 Jul 2004 10:07:04 -0000	1.83
+++ gedit-mdi.c	4 Aug 2004 21:32:01 -0000
@@ -80,6 +80,8 @@ typedef struct _GeditWindowPrefs	GeditWi
 
 struct _GeditWindowPrefs
 {
+	GtkWrapMode wrap_mode;
+
 	gboolean toolbar_visible;
 	GeditToolbarSetting toolbar_buttons_style;
 
@@ -99,6 +101,7 @@ static void gedit_mdi_drag_data_received
 				                  guint info, guint time);
 static void gedit_mdi_set_app_toolbar_style 	(BonoboWindow *win);
 static void gedit_mdi_set_app_statusbar_style 	(BonoboWindow *win);
+static void gedit_mdi_set_app_wrap_mode 	(BonoboWindow *win);
 
 static gint gedit_mdi_add_child_handler (BonoboMDI *mdi, BonoboMDIChild *child);
 static gint gedit_mdi_add_view_handler (BonoboMDI *mdi, GtkWidget *view);
@@ -522,6 +525,20 @@ gedit_mdi_app_created_handler (BonoboMDI
 	prefs = gedit_window_prefs_new ();
 	gedit_window_prefs_attach_to_window (prefs, win);
 
+	/* Set the wrap mode according to prefs */
+	gedit_mdi_set_app_wrap_mode (win);
+
+	/* Add listener to the Edit -> Wrap Mode menu */
+	bonobo_ui_component_add_listener (ui_component, "WrapModeNone", 
+			(BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, 
+			(gpointer)win);
+	bonobo_ui_component_add_listener (ui_component, "WrapModeWord", 
+			(BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, 
+			(gpointer)win);
+	bonobo_ui_component_add_listener (ui_component, "WrapModeChar", 
+			(BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, 
+			(gpointer)win);
+
 	/* Set the statusbar style according to prefs */
 	gedit_mdi_set_app_statusbar_style (win);
 	
@@ -635,6 +652,39 @@ gedit_mdi_view_menu_item_toggled_handler
 
 	s = (strcmp (state, "1") == 0);
 
+	if (strcmp (path, "WrapModeNone") == 0)
+	{
+		if (prefs->wrap_mode != GTK_WRAP_NONE)
+		{
+			prefs->wrap_mode = GTK_WRAP_NONE;
+			gedit_mdi_set_app_wrap_mode (win);
+		}
+
+		goto save_prefs;
+	}
+
+	if (strcmp (path, "WrapModeWord") == 0)
+	{
+		if (prefs->wrap_mode != GTK_WRAP_WORD)
+		{
+			prefs->wrap_mode = GTK_WRAP_WORD;
+			gedit_mdi_set_app_wrap_mode (win);
+		}
+
+		goto save_prefs;
+	}
+
+	if (strcmp (path, "WrapModeChar") == 0)
+	{
+		if (prefs->wrap_mode != GTK_WRAP_CHAR)
+		{
+			prefs->wrap_mode = GTK_WRAP_CHAR;
+			gedit_mdi_set_app_wrap_mode (win);
+		}
+
+		goto save_prefs;
+	}
+
 	if (strcmp (path, "ViewToolbar") == 0)
 	{
 		if (s != prefs->toolbar_visible)
@@ -894,6 +944,39 @@ gedit_mdi_set_app_statusbar_style (Bonob
 	bonobo_ui_component_thaw (ui_component, NULL);
 }
 
+static void
+gedit_mdi_set_app_wrap_mode (BonoboWindow *win)
+{
+	BonoboUIComponent *ui_component;
+	GeditWindowPrefs *prefs = NULL;
+
+	gedit_debug (DEBUG_MDI, "");
+	
+	g_return_if_fail (BONOBO_IS_WINDOW (win));
+	
+	prefs = gedit_window_prefs_get_from_window (win);
+	g_return_if_fail (prefs != NULL);
+	
+	ui_component = bonobo_mdi_get_ui_component_from_window (win);
+	g_return_if_fail (ui_component != NULL);
+
+	bonobo_ui_component_freeze (ui_component, NULL);
+
+	gedit_menus_set_verb_state (ui_component, 
+				    "/commands/WrapModeNone",
+				    prefs->wrap_mode == GTK_WRAP_NONE);
+
+	gedit_menus_set_verb_state (ui_component, 
+				    "/commands/WrapModeWord",
+				    prefs->wrap_mode == GTK_WRAP_WORD);
+
+	gedit_menus_set_verb_state (ui_component, 
+				    "/commands/WrapModeChar",
+				    prefs->wrap_mode == GTK_WRAP_CHAR);
+
+	bonobo_ui_component_thaw (ui_component, NULL);
+}
+
 static void 
 gedit_mdi_child_state_changed_handler (GeditMDIChild *child)
 {
@@ -1677,6 +1760,8 @@ gedit_window_prefs_new (void)
 
 	prefs = g_new0 (GeditWindowPrefs, 1);
 
+	prefs->wrap_mode = gedit_prefs_manager_get_wrap_mode ();
+
 	prefs->toolbar_visible = gedit_prefs_manager_get_toolbar_visible ();
 	prefs->toolbar_buttons_style = gedit_prefs_manager_get_toolbar_buttons_style ();
 
@@ -1723,6 +1808,10 @@ gedit_window_prefs_save (GeditWindowPref
 	gedit_debug (DEBUG_MDI, "");
 
 	g_return_if_fail (prefs != NULL);
+
+	if ((prefs->wrap_mode != gedit_prefs_manager_get_wrap_mode ()) &&
+	     gedit_prefs_manager_wrap_mode_can_set ())
+		gedit_prefs_manager_set_wrap_mode (prefs->wrap_mode);
 
 	if ((prefs->toolbar_visible != gedit_prefs_manager_get_toolbar_visible ()) &&
 	     gedit_prefs_manager_toolbar_visible_can_set ())
Index: gedit-prefs-manager-app.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-prefs-manager-app.c,v
retrieving revision 1.4
diff -u -p -r1.4 gedit-prefs-manager-app.c
--- gedit-prefs-manager-app.c	5 Mar 2004 16:50:22 -0000	1.4
+++ gedit-prefs-manager-app.c	4 Aug 2004 21:32:16 -0000
@@ -610,6 +610,23 @@ gedit_prefs_manager_wrap_mode_changed (G
 			children = children->next;
 		}
 	}
+	
+	/* Update the toggle on the Edit -> Wrap Mode Menu */
+
+	BonoboWindow *win;
+	BonoboUIComponent *ui_component;
+	GtkWrapMode wrap_mode;
+
+	win = gedit_get_active_window ();
+	g_return_if_fail (win != NULL);
+
+	ui_component = bonobo_mdi_get_ui_component_from_window (win);
+	g_return_if_fail (ui_component != NULL);
+
+	wrap_mode = gedit_prefs_manager_get_wrap_mode ();
+	gedit_menus_set_verb_state (ui_component, "/commands/WrapModeNone", wrap_mode == GTK_WRAP_NONE);
+	gedit_menus_set_verb_state (ui_component, "/commands/WrapModeWord", wrap_mode == GTK_WRAP_WORD);
+	gedit_menus_set_verb_state (ui_component, "/commands/WrapModeChar", wrap_mode == GTK_WRAP_CHAR);
 
 }
 
Index: gedit-ui.xml
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-ui.xml,v
retrieving revision 1.52
diff -u -p -r1.52 gedit-ui.xml
--- gedit-ui.xml	12 Feb 2004 12:17:43 -0000	1.52
+++ gedit-ui.xml	4 Aug 2004 21:32:19 -0000
@@ -73,6 +73,15 @@
 	<cmd name="EditSelectAll" _label="Select All" _tip="Select the entire document"
 	accel="*Control*A"/>     
 
+       <cmd name="WrapModeNone" id="WrapModeNone" _label="_None" type="radio" 
+         group="wrap" _tip="Disable wrapping of text"/>
+
+	<cmd name="WrapModeWord" id="WrapModeWord" _label="_Word" type="radio" 
+	 group="wrap" _tip="Wrap text at word boundaries"/>
+
+	<cmd name="WrapModeChar" id="WrapModeChar" _label="_Character" type="radio" 
+	 group="wrap" _tip ="Wrap text at character boundaries"/>
+
 	<cmd name="SearchFind" _label="Find" _tip="Search for text"
         pixtype="stock" pixname="gtk-find" accel="*Control*F"/>
 	
@@ -186,6 +195,18 @@
 	<placeholder name="EditOps_2" /> 
 
         <menuitem name="EditSelectAll" verb="" _label="Select _All"/>
+
+	<separator/>
+
+	<submenu name="EditWrapMode" _label="_Wrap Mode">
+		
+		<menuitem name="WrapModeNone" verb=""/>
+
+		<menuitem name="WrapModeWord" verb=""/>
+
+		<menuitem name="WrapModeChar" verb=""/>
+                 
+	</submenu>
 
 	<placeholder name="EditOps_3" /> 
 
