[gnome-applets] Prevent sticky notes getting too large



commit aa1b99fe4d0b958e9ae61e6f8159395a339cff5f
Author: Callum McKenzie <callum spooky-possum org>
Date:   Wed Apr 29 21:18:31 2009 +1200

    Prevent sticky notes getting too large
    
    Patch from Dennis Hilmar to add a scroll bar when the note gets more
    than 80% of the screen size. See bug 121883.
---
 stickynotes/ChangeLog            |    9 +++++++++
 stickynotes/stickynotes.c        |    9 +++++++--
 stickynotes/stickynotes.h        |    1 +
 stickynotes/stickynotes.ui       |   17 ++++++++++++-----
 stickynotes/stickynotes_applet.c |    3 +++
 stickynotes/stickynotes_applet.h |    1 +
 6 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/stickynotes/ChangeLog b/stickynotes/ChangeLog
index 8eb1446..4d4e517 100644
--- a/stickynotes/ChangeLog
+++ b/stickynotes/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-29  Callum McKenzie  <callum spooky-possum org>
+
+	* stickynotes.ui:
+	* stickynotes_applet.c:
+	* stickynotes_applet.h:
+	* stickynotes.c:
+	* sticknotes.h: Patch from Dennis Hilmar to add scroll bars if the
+	note gets too large. (Bug: 121883)
+
 2009-04-06  Callum McKenzie  <callum spooky-possum org>
 
 	* stickynotes.glade: 
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index bd7e9a9..fab5f87 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -73,8 +73,12 @@ timeout_happened (gpointer data)
 
 /* Called when a text buffer is changed.  */
 static void
-buffer_changed (GtkTextBuffer *buffer, gpointer data)
+buffer_changed (GtkTextBuffer *buffer, StickyNote *note)
 {
+	if ( (note->h + note->y) > stickynotes->max_height )
+		gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW(note->w_scroller), 
+													GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
 	/* When a buffer is changed, we set a 10 second timer.  When
 	   the timer triggers, we will save the buffer if there have
 	   been no subsequent changes.  */
@@ -106,6 +110,7 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
 
 	note->w_title = GTK_WIDGET (gtk_builder_get_object (builder, "title_label"));
 	note->w_body = GTK_WIDGET (gtk_builder_get_object (builder, "body_text"));
+	note->w_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "body_scroller"));
 	note->w_lock = GTK_WIDGET (gtk_builder_get_object (builder, "lock_button"));
 	gtk_widget_add_events (note->w_lock, GDK_BUTTON_PRESS_MASK);
 
@@ -284,7 +289,7 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
 
 	g_signal_connect (gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body)),
 			  "changed",
-			  G_CALLBACK (buffer_changed), NULL);
+			  G_CALLBACK (buffer_changed), note);
 
 	return note;
 }
diff --git a/stickynotes/stickynotes.h b/stickynotes/stickynotes.h
index bffe28a..1339571 100644
--- a/stickynotes/stickynotes.h
+++ b/stickynotes/stickynotes.h
@@ -42,6 +42,7 @@ typedef struct
 
 	GtkWidget *w_title;		/* Sticky Note title */
 	GtkWidget *w_body;		/* Sticky Note text body */
+        GtkWidget *w_scroller;          /* Sticky Note scroller */
 	GtkWidget *w_lock;		/* Sticky Note lock button */
 	GtkWidget *w_close;		/* Sticky Note close button */
 	GtkWidget *w_resize_se;		/* Sticky Note resize button (south east) */
diff --git a/stickynotes/stickynotes.ui b/stickynotes/stickynotes.ui
index 2381bff..06a99d1 100644
--- a/stickynotes/stickynotes.ui
+++ b/stickynotes/stickynotes.ui
@@ -731,13 +731,20 @@ This cannot be undone.</property>
           </packing>
         </child>
         <child>
-          <object class="GtkTextView" id="body_text">
+	  <object class="GtkScrolledWindow" id="body_scroller">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="has_focus">True</property>
-            <property name="wrap_mode">GTK_WRAP_WORD</property>
-            <property name="left_margin">4</property>
-            <property name="right_margin">4</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">never</property>
+            <child>
+              <object class="GtkTextView" id="body_text">
+		<property name="visible">True</property>
+		<property name="can_focus">True</property>
+		<property name="wrap_mode">GTK_WRAP_WORD</property>
+		<property name="left_margin">4</property>
+		<property name="right_margin">4</property>
+	      </object>
+	    </child>
           </object>
           <packing>
             <property name="position">1</property>
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 45ca8df..5c27578 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -163,6 +163,9 @@ stickynotes_applet_init (PanelApplet *panel_applet)
 	gconf_client_notify_add (stickynotes->gconf, GCONF_PATH "/settings",
 			(GConfClientNotifyFunc) preferences_apply_cb,
 			NULL, NULL, NULL);
+
+	/* Max height for large notes*/
+	stickynotes->max_height = 0.8*gdk_screen_get_height( gdk_screen_get_default() );
 	
 	/* Load sticky notes */
 	stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (panel_applet)));
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index 92a6428..ddc2028 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -62,6 +62,7 @@ typedef struct
 
 	GConfClient *gconf;		/* GConf Client */
 
+	gint max_height;
 	guint last_timeout_data;
 
     gboolean visible;       /* Toggle show/hide notes */



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