[gnome-mud] Re: Input Patch



Apparently cvs diff -u wasn't finished yet. Whoops. Here's the real
patch.

On Thu, 2005-12-29 at 01:55 -0800, Les Harris wrote:
> Here is the patch that adds support for the re-sizable input widget.
> 
> Les 
? input.patch
? ui/main.gladep
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mud/ChangeLog,v
retrieving revision 1.342
diff -u -u -r1.342 ChangeLog
--- ChangeLog	29 Dec 2005 08:47:01 -0000	1.342
+++ ChangeLog	29 Dec 2005 09:57:16 -0000
@@ -1,3 +1,7 @@
+2005-12-29  Les Harris  <lescom comcast net>
+
+	* src/mud-window.c, ui/main.glade: Added resizable entry widget support.
+
 2005-12-29  Robin Ericsson  <lobbin localhost nu>
 
 	* Applied new GtkAboutDialog from Les Harris.
Index: src/mud-window.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-window.c,v
retrieving revision 1.6
diff -u -u -r1.6 mud-window.c
--- src/mud-window.c	29 Dec 2005 08:47:01 -0000	1.6
+++ src/mud-window.c	29 Dec 2005 09:57:16 -0000
@@ -10,6 +10,11 @@
 #include <gtk/gtkmain.h>
 #include <gtk/gtknotebook.h>
 #include <gtk/gtkwidget.h>
+#include <gtk/gtkpaned.h>
+#include <gtk/gtktextview.h>
+#include <gtk/gtktextbuffer.h>
+#include <gtk/gtktextiter.h>
+#include <gdk/gdkkeysyms.h>
 #include <libgnome/gnome-i18n.h>
 #include <stdlib.h>
 
@@ -28,6 +33,9 @@
 	GtkWidget *window;
 	GtkWidget *notebook;
 	GtkWidget *textentry;
+	GtkWidget *textview;
+	GtkWidget *textviewscroll;
+	GtkWidget *mainvpane;
 
 	GtkWidget *blank_label;
 	GtkWidget *current_view;
@@ -36,6 +44,7 @@
 	gchar *port;
 
 	gint nr_of_tabs;
+	gint toggleState;
 };
 
 static int
@@ -116,6 +125,32 @@
 	return FALSE;
 }
 
+static gboolean
+mud_window_textview_keypress(GtkWidget *widget, GdkEventKey *event, MudWindow *window)
+{
+	gchar *text;
+        GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->priv->textview));
+	GtkTextIter start, end;
+	
+	if(event->keyval == GDK_KP_Enter)
+	{
+		if(window->priv->current_view)
+		{
+			gtk_text_buffer_get_bounds(buffer, &start, &end);
+	
+			text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+			mud_connection_view_send(MUD_CONNECTION_VIEW(window->priv->current_view), text);
+			
+			gtk_text_buffer_select_range(buffer, &start, &end);
+
+			return TRUE;
+			
+		}
+	}
+
+	return FALSE;
+}
+
 static void
 mud_window_notebook_page_change(GtkNotebook *notebook, GtkNotebookPage *page, gint arg, MudWindow *window)
 {
@@ -168,6 +203,51 @@
 }
 
 static void
+mud_window_inputtoggle_cb(GtkWidget *widget, MudWindow *window)
+{
+	gint w, h;
+	
+	if(window->priv->toggleState)
+	{
+		gtk_widget_hide(window->priv->textview);
+		gtk_widget_hide(window->priv->textviewscroll);
+		gtk_widget_show(window->priv->textentry);
+
+		gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
+	
+		gtk_paned_set_position(GTK_PANED(window->priv->mainvpane),h - 62);
+
+		window->priv->toggleState = 0;	
+	}
+	else
+	{
+		gtk_widget_hide(window->priv->textentry);
+		gtk_widget_show(window->priv->textview);
+		gtk_widget_show(window->priv->textviewscroll);	
+
+		gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
+	
+		gtk_paned_set_position(GTK_PANED(window->priv->mainvpane),h - 124);
+		
+		window->priv->toggleState = 1;
+	}
+}
+
+gboolean
+mud_window_size_request(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
+{	
+	gint w, h;
+	MudWindow *window = (MudWindow *)user_data;
+	
+	gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
+	
+	if(!window->priv->toggleState)
+		gtk_paned_set_position(GTK_PANED(window->priv->mainvpane),h - 62);
+
+	return FALSE;
+}
+
+static void
 mud_window_connect_dialog(GtkWidget *widget, MudWindow *window)
 {
 	GladeXML *glade;
@@ -250,6 +330,7 @@
 {
 	GladeXML *glade;
 	gchar buf[1024];
+	gint w, h;
 	
 	window->priv = g_new0(MudWindowPrivate, 1);
 
@@ -294,10 +375,27 @@
 	window->priv->notebook = glade_xml_get_widget(glade, "notebook");
 	g_signal_connect(window->priv->notebook, "switch-page", G_CALLBACK(mud_window_notebook_page_change), window);
 
+	window->priv->textviewscroll = glade_xml_get_widget(glade, "text_view_scroll");
+	window->priv->textview = glade_xml_get_widget(glade, "text_view");
+
+	g_signal_connect(window->priv->textview, "key_press_event", G_CALLBACK(mud_window_textview_keypress), window);
+	
+	gtk_widget_hide(window->priv->textviewscroll);
+	gtk_widget_hide(window->priv->textview);
+	
+	window->priv->toggleState = 0;
+
 	window->priv->textentry = glade_xml_get_widget(glade, "text_entry");
 	g_signal_connect(window->priv->textentry, "key_press_event", G_CALLBACK(mud_window_textentry_keypress), window);
 	g_signal_connect(window->priv->textentry, "activate", G_CALLBACK(mud_window_textentry_activate), window);
 
+	window->priv->mainvpane = glade_xml_get_widget(glade, "main_vpane");
+	gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
+	
+	gtk_paned_set_position(GTK_PANED(window->priv->mainvpane),h - 62);
+	
+	g_signal_connect(glade_xml_get_widget(glade, "toggle_input"), "clicked", G_CALLBACK(mud_window_inputtoggle_cb), window);
+
 	window->priv->current_view = NULL;
 	window->priv->nr_of_tabs = 0;
 	window->priv->blank_label = glade_xml_get_widget(glade, "startup_label");
@@ -309,6 +407,8 @@
 							VERSION, __TIME__, __DATE__);
 	gtk_label_set_text(GTK_LABEL(window->priv->blank_label), buf);
 	
+	g_signal_connect(window->priv->window, "configure-event", G_CALLBACK(mud_window_size_request), window);
+
 	g_object_unref(glade);
 }
 
Index: ui/main.glade
===================================================================
RCS file: /cvs/gnome/gnome-mud/ui/main.glade,v
retrieving revision 1.4
diff -u -u -r1.4 main.glade
--- ui/main.glade	29 Dec 2005 08:47:02 -0000	1.4
+++ ui/main.glade	29 Dec 2005 09:57:18 -0000
@@ -45,12 +45,12 @@
 		  <child>
 		    <widget class="GtkImageMenuItem" id="main_connect">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Connection Wizard...</property>
+		      <property name="label" translatable="yes">Connection...</property>
 		      <property name="use_underline">True</property>
 		      <signal name="activate" handler="on_connection_wizard1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image43">
+			<widget class="GtkImage" id="image57">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-new</property>
 			  <property name="icon_size">1</property>
@@ -66,12 +66,12 @@
 		  <child>
 		    <widget class="GtkImageMenuItem" id="menu_mudlist">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">MudList Listing...</property>
+		      <property name="label" translatable="yes">Mud List...</property>
 		      <property name="use_underline">True</property>
 		      <signal name="activate" handler="on_mudlist_listing1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image44">
+			<widget class="GtkImage" id="image58">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-new</property>
 			  <property name="icon_size">1</property>
@@ -93,12 +93,12 @@
 		  <child>
 		    <widget class="GtkImageMenuItem" id="menu_connect">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Connect...</property>
+		      <property name="label" translatable="yes">Quick Connect...</property>
 		      <property name="use_underline">True</property>
 		      <signal name="activate" handler="on_connect1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image45">
+			<widget class="GtkImage" id="image59">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-open</property>
 			  <property name="icon_size">1</property>
@@ -119,7 +119,7 @@
 		      <signal name="activate" handler="on_disconnect1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image46">
+			<widget class="GtkImage" id="image60">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-close</property>
 			  <property name="icon_size">1</property>
@@ -140,7 +140,7 @@
 		      <signal name="activate" handler="on_reconnect1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image47">
+			<widget class="GtkImage" id="image61">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-refresh</property>
 			  <property name="icon_size">1</property>
@@ -167,7 +167,7 @@
 		      <signal name="activate" handler="on_start_logging1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image48">
+			<widget class="GtkImage" id="image62">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-new</property>
 			  <property name="icon_size">1</property>
@@ -188,7 +188,7 @@
 		      <signal name="activate" handler="on_stop_logging1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image49">
+			<widget class="GtkImage" id="image63">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-close</property>
 			  <property name="icon_size">1</property>
@@ -209,7 +209,7 @@
 		      <signal name="activate" handler="on_save_buffer1_activate" last_modification_time="Mon, 16 Feb 2004 12:51:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image50">
+			<widget class="GtkImage" id="image64">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-save</property>
 			  <property name="icon_size">1</property>
@@ -347,58 +347,176 @@
       </child>
 
       <child>
-	<widget class="GtkNotebook" id="notebook">
+	<widget class="GtkVPaned" id="main_vpane">
 	  <property name="visible">True</property>
-	  <property name="show_tabs">False</property>
-	  <property name="show_border">True</property>
-	  <property name="tab_pos">GTK_POS_TOP</property>
-	  <property name="scrollable">False</property>
-	  <property name="enable_popup">False</property>
+	  <property name="can_focus">True</property>
+	  <property name="position">314</property>
 
 	  <child>
-	    <widget class="GtkLabel" id="startup_label">
+	    <widget class="GtkNotebook" id="notebook">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes"></property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.469999998808</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-	      <property name="width_chars">-1</property>
-	      <property name="single_line_mode">False</property>
-	      <property name="angle">0</property>
+	      <property name="show_tabs">False</property>
+	      <property name="show_border">True</property>
+	      <property name="tab_pos">GTK_POS_TOP</property>
+	      <property name="scrollable">False</property>
+	      <property name="enable_popup">False</property>
+
+	      <child>
+		<widget class="GtkLabel" id="startup_label">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes"></property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="tab_expand">False</property>
+		  <property name="tab_fill">True</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label37">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">label37</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="type">tab</property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
-	      <property name="tab_expand">False</property>
-	      <property name="tab_fill">True</property>
+	      <property name="shrink">True</property>
+	      <property name="resize">False</property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkLabel" id="label1">
+	    <widget class="GtkHBox" id="hbox6">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">label1</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-	      <property name="width_chars">-1</property>
-	      <property name="single_line_mode">False</property>
-	      <property name="angle">0</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<widget class="GtkVBox" id="vbox4">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">0</property>
+
+		  <child>
+		    <widget class="GtkEntry" id="text_entry">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="editable">True</property>
+		      <property name="visibility">True</property>
+		      <property name="max_length">0</property>
+		      <property name="text" translatable="yes"></property>
+		      <property name="has_frame">True</property>
+		      <property name="invisible_char">*</property>
+		      <property name="activates_default">False</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkScrolledWindow" id="text_view_scroll">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+		      <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+		      <property name="shadow_type">GTK_SHADOW_IN</property>
+		      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+		      <child>
+			<widget class="GtkTextView" id="text_view">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="editable">True</property>
+			  <property name="overwrite">False</property>
+			  <property name="accepts_tab">True</property>
+			  <property name="justification">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap_mode">GTK_WRAP_NONE</property>
+			  <property name="cursor_visible">True</property>
+			  <property name="pixels_above_lines">0</property>
+			  <property name="pixels_below_lines">0</property>
+			  <property name="pixels_inside_wrap">0</property>
+			  <property name="left_margin">0</property>
+			  <property name="right_margin">0</property>
+			  <property name="indent">0</property>
+			  <property name="text" translatable="yes"></property>
+			</widget>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">True</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">True</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkButton" id="toggle_input">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+
+		  <child>
+		    <widget class="GtkImage" id="image65">
+		      <property name="visible">True</property>
+		      <property name="stock">gtk-justify-fill</property>
+		      <property name="icon_size">1</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
-	      <property name="type">tab</property>
+	      <property name="shrink">True</property>
+	      <property name="resize">True</property>
 	    </packing>
 	  </child>
 	</widget>
@@ -406,25 +524,6 @@
 	  <property name="padding">0</property>
 	  <property name="expand">True</property>
 	  <property name="fill">True</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkEntry" id="text_entry">
-	  <property name="visible">True</property>
-	  <property name="can_focus">True</property>
-	  <property name="editable">True</property>
-	  <property name="visibility">True</property>
-	  <property name="max_length">0</property>
-	  <property name="text" translatable="yes"></property>
-	  <property name="has_frame">True</property>
-	  <property name="invisible_char">*</property>
-	  <property name="activates_default">False</property>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">False</property>
 	</packing>
       </child>
     </widget>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]