[Glade-devel] [glade3] GtkNotebook PATCH



--=-sxG17p9Ba+Y9nzXZGb97
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

I have created a new patch for GtkNotebook related stuff. It includes
the last one but also makes the tab labels use GladeWidgets, which can
be selected/edited/deleted. Anyone able to review?

-Shane

On Sun, 2004-08-29 at 23:01, Shane Butler wrote:
Hi all,

Please find attached a patch to fix a few GtkNotebook bits and pieces.
Firstly it hooks up the post create function for the GtkNotebook widget,
so you now get a dialog asking how many pages the notebook should have.
Secondly it blocks the fill empty function (this was creating notebooks
of size+1). Finally I set the minimum size of the GtkBox and GtkNotebook
dialogs to be 1.

Could someone please review and commit if it is ok?!

Cheers, Shane

--=-sxG17p9Ba+Y9nzXZGb97
Content-Disposition: attachment; filename=glade3-gtknotebook2.patch
Content-Type: text/x-patch; name=glade3-gtknotebook2.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: glade3/ChangeLog
===================================================================
RCS file: /cvs/gnome/glade3/ChangeLog,v
retrieving revision 1.299
diff -u -r1.299 ChangeLog
--- glade3/ChangeLog    26 Jul 2004 10:37:23 -0000      1.299
+++ glade3/ChangeLog    30 Aug 2004 10:36:15 -0000
@@ -1,3 +1,20 @@
+2004-07-30  Shane Butler  <shane_b users sourceforge net>
+
+       * src/glade-gtk.c (glade_gtk_notebook_set_n_pages, 
+       glade_gtk_notebook_replace_child, 
+       glade_gtk_notebook_child_property_applies): Make new notebook pages
+       use GladeWidgets for thier labels (now selectable/editable/etc), and
+       Tab labels can now be deleted (replaced with placeholder).
+       * widgets/gtknotebook.xml: Link the child property applies func.
+
+2004-07-29  Shane Butler  <shane_b users sourceforge net>
+
+       * src/glade-gtk.c (glade_gtk_notebook_post_create, 
+       glade_gtk_box_post_create): Fix notebook size query and make both
+       GktBox and GtkNotebook ask for size > 1.
+       * widgets/gtknotebook.xml: Link the post create function and do 
+       not fill empty (has the effect of adding an extra tab).
+
 2004-07-26  Shane Butler  <shane_b users sourceforge net>
 
        * widgets/gtkbox.xml: Fixed bug with loading GtkBoxes where too
Index: glade3/src/glade-gtk.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-gtk.c,v
retrieving revision 1.48
diff -u -r1.48 glade-gtk.c
--- glade3/src/glade-gtk.c      8 May 2004 20:01:30 -0000       1.48
+++ glade3/src/glade-gtk.c      30 Aug 2004 10:36:20 -0000
@@ -25,6 +25,7 @@
 
 #include <gtk/gtk.h>
 #include "glade-plugin.h"
+#include "glade-project-window.h"
 
 /* Borrow from libgnome/libgnome.h */
 #ifdef ENABLE_NLS
@@ -367,11 +368,25 @@
 
        if (new_size > old_size) {
                /* The notebook has grown. Add a page. */
+               GladeWidgetClass *label_klass;
+               GladeProjectWindow *gpw;
+               GladeWidget *tab_label;
+               GladeProperty *tab_label_text;
+               GValue *str_label;
+
+               gpw = glade_project_window_get ();
                while (new_size > old_size) {
                        GladePlaceholder *placeholder = GLADE_PLACEHOLDER (glade_placeholder_new ());
+                       label_klass = glade_widget_class_get_by_name ("GtkLabel");
+                       tab_label = glade_widget_new (label_klass, gpw->project);
+                       tab_label_text = glade_widget_get_property (tab_label, "label");
+                       str_label = g_new0 (GValue, 1);
+                       g_value_init (str_label, G_TYPE_STRING);
+                       g_value_set_string (str_label, glade_widget_get_name (tab_label));
+                       glade_property_set (tab_label_text, str_label);
                        gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                                                  GTK_WIDGET (placeholder),
-                                                 NULL);
+                                                 tab_label->widget);
                        old_size++;
                }
        } else {/* new_size < old_size */
@@ -663,7 +678,7 @@
        GValue value = {0,};
 
        g_value_init (&value, G_TYPE_INT);
-       g_value_set_int (&value, ask_for_number(_("Create a box"), _("Number of items:"), 0, 10000, 3));
+       g_value_set_int (&value, ask_for_number(_("Create a box"), _("Number of items:"), 1, 10000, 3));
 
        glade_property_set (property, &value);
 }
@@ -671,11 +686,13 @@
 void GLADEGTK_API
 glade_gtk_notebook_post_create (GObject *object)
 {
-       GladeProperty *property = glade_widget_get_property (glade_widget_get_from_gtk_widget (object), 
"size");
+       GladeProperty *property = glade_widget_get_property (glade_widget_get_from_gtk_widget (object), 
"pages");
        GValue value = {0,};
 
        g_value_init (&value, G_TYPE_INT);
-       g_value_set_int (&value, ask_for_number(_("Create a notebook"), _("Number of pages:"), 0, 100, 3));
+       g_value_set_int (&value, ask_for_number(_("Create a notebook"), _("Number of pages:"), 1, 100, 3));
+
+       glade_property_set (property, &value);
 }
 
 void GLADEGTK_API
@@ -884,7 +901,14 @@
        notebook = GTK_NOTEBOOK (container);
        page_num = gtk_notebook_page_num (notebook, current);
        if (page_num == -1) {
-               g_warning ("GtkNotebookPage not found\n");
+               /* GtkNotebookPage not found: probably a tab label */
+               for (page_num = 0; page_num < g_list_length (notebook->children); page_num++) {
+                       page = gtk_notebook_get_nth_page (notebook, page_num);
+                       if (gtk_notebook_get_tab_label (notebook, page) == current) {
+                               gtk_notebook_set_tab_label (notebook, page, new);
+                               break;
+                       }
+               }
                return;
        }
 
@@ -978,3 +1002,16 @@
        return FALSE;
 }
 
+int GLADEGTK_API
+glade_gtk_notebook_child_property_applies (GtkWidget *ancestor,
+                                        GtkWidget *widget,
+                                        const char *property_id)
+{
+       g_return_val_if_fail (GTK_IS_NOTEBOOK (ancestor), FALSE);
+
+       if (gtk_notebook_page_num (GTK_NOTEBOOK (ancestor), widget) >= 0)
+               return TRUE;
+       else
+               return FALSE;
+}
+
Index: glade3/widgets/gtknotebook.xml
===================================================================
RCS file: /cvs/gnome/glade3/widgets/gtknotebook.xml,v
retrieving revision 1.11
diff -u -r1.11 gtknotebook.xml
--- glade3/widgets/gtknotebook.xml      20 Oct 2003 18:16:34 -0000      1.11
+++ glade3/widgets/gtknotebook.xml      30 Aug 2004 10:36:20 -0000
@@ -1,6 +1,9 @@
 <GladeWidgetClass>
 
+  <PostCreateFunction>glade_gtk_notebook_post_create</PostCreateFunction>
   <ReplaceChildFunction>glade_gtk_notebook_replace_child</ReplaceChildFunction>
+  <FillEmptyFunction>ignore</FillEmptyFunction>
+  <ChildPropertyApplies>glade_gtk_notebook_child_property_applies</ChildPropertyApplies>
 
   <Properties>
 
@@ -12,7 +15,7 @@
         <Parameter Key="Max" Value="100"/>
         <Parameter Key="StepIncrement" Value="1"/>
         <Parameter Key="PageIncrement" Value="1"/>
-        <Parameter Key="ClibmRate" Value="1"/>
+        <Parameter Key="ClimbRate" Value="1"/>
       </Parameters>
       <Query>
         <Question>Number of pages</Question>

--=-sxG17p9Ba+Y9nzXZGb97--





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