patch: changable shadow for gtk_entry




Hi!

This patch adds the function gtk_entry_set_shadow_type.
It's against the cvs-tree from I think May 12.

I wrote it, because imo the gtk_combo widget looks better (at least
if you don't want the user to enter any text) when it has an
GTK_SHADOW_OUT instead of GTK_SHADOW_IN.

Nearly anything I modified is copied from gtk_frame.

I'm not sure wether the gdk_window_clear_area and gtk_widget_queue_resize
are nessesary. Someone should check that.

Below the patch for gtk_entry there's a patch for testgtk.c which
makes the combo box in the entry-demo uneditable and sets GTK_SHADOW_OUT.

I hope i submitted it the right way.... as it is my first contribution
(or should I better upload it to the ftp-server?)

btw: are daily patches from cvs available somewhere? cvs-access is quite
difficult for me :( Or at least the whole thing tgz'ed?

Roni   (IRC: _crash)


diff -r -u gtk+/gtk/gtkentry.c gtk+neu/gtk/gtkentry.c
--- gtk+/gtk/gtkentry.c	Sat May 16 18:49:53 1998
+++ gtk+neu/gtk/gtkentry.c	Sat May 16 18:47:51 1998
@@ -258,6 +258,8 @@
   entry->timer = 0;
   entry->button = 0;
   entry->visible = 1;
+  entry->shadow_type = GTK_SHADOW_IN;
+
 
   entry->nchars = 0;
   entry->char_pos = NULL;
@@ -385,6 +387,30 @@
   return entry->text;
 }
 
+void
+gtk_entry_set_shadow_type (GtkEntry      *entry,
+                           GtkShadowType  type)
+{
+  g_return_if_fail (entry != NULL);
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  if ((GtkShadowType) entry->shadow_type != type)
+    {
+      entry->shadow_type = type;
+
+      if (GTK_WIDGET_DRAWABLE (entry))
+        {
+          gdk_window_clear_area (GTK_WIDGET (entry)->window,
+                                 GTK_WIDGET (entry)->allocation.x,
+                                 GTK_WIDGET (entry)->allocation.y,
+                                 GTK_WIDGET (entry)->allocation.width,
+                                 GTK_WIDGET (entry)->allocation.height);
+        }
+      gtk_widget_queue_resize (GTK_WIDGET (entry));
+    }
+}
+  
+
 static void
 gtk_entry_finalize (GtkObject *object)
 {
@@ -604,7 +630,7 @@
 	}
 
       gtk_draw_shadow (widget->style, widget->window,
-		       GTK_STATE_NORMAL, GTK_SHADOW_IN,
+		       GTK_STATE_NORMAL, GTK_ENTRY(widget)->shadow_type,
 		       x, y, width, height);
 
       if (GTK_WIDGET_HAS_FOCUS (widget))
diff -r -u gtk+/gtk/gtkentry.h gtk+neu/gtk/gtkentry.h
--- gtk+/gtk/gtkentry.h	Sat May 16 18:49:53 1998
+++ gtk+neu/gtk/gtkentry.h	Sat May 16 18:47:47 1998
@@ -46,6 +46,7 @@
   GdkCursor *cursor;
   gchar *text;
 
+  gint16 shadow_type;
   guint16 text_size;
   guint16 text_length;
   guint16 text_max_length;
@@ -93,6 +94,9 @@
 /* text is truncated if needed */
 void       gtk_entry_set_max_length (GtkEntry      *entry,
 				     guint16        max);
+
+void	gtk_entry_set_shadow_type(	GtkEntry	*entry, 
+					GtkShadowType type);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */




diff -r -u gtk+/gtk/testgtk.c gtk+neu/gtk/testgtk.c
--- gtk+/gtk/testgtk.c	Sat May 16 19:16:16 1998
+++ gtk+neu/gtk/testgtk.c	Sat May 16 19:19:07 1998
@@ -2277,9 +2277,9 @@
 
       cb = gtk_combo_new ();
       gtk_combo_set_popdown_strings (GTK_COMBO (cb), cbitems);
-      gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world");
-      gtk_editable_select_region (GTK_EDITABLE (GTK_COMBO(cb)->entry),
-				  0, -1);
+      gtk_entry_set_shadow_type( GTK_ENTRY(GTK_COMBO(cb)->entry), GTK_SHADOW_OUT);
+      gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(cb)->entry), FALSE);
+      
       gtk_box_pack_start (GTK_BOX (box2), cb, TRUE, TRUE, 0);
       gtk_widget_show (cb);
 



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