GtkNotebook focus patch



Hi !

Focus changes in GtkNotebook look very ugly and buggy since the
themes merge. I wanted to fix it a bit, but I'm not completely
sure if my fix is ok for themes (although all gtk-engine themes
work with this fix).

So please check this patch. I'll commit it, if nobody objects.

bye,
  Lars

-------------------------------------------------------------
diff -ruN gtk+.orig/gtk/gtknotebook.c gtk+/gtk/gtknotebook.c
--- gtk+.orig/gtk/gtknotebook.c Wed Nov 18 21:26:49 1998
+++ gtk+/gtk/gtknotebook.c      Wed Nov 18 21:30:03 1998
@@ -1313,12 +1313,12 @@
 
       page = notebook->focus_tab->data;
 
-      area.x = widget->allocation.x;
-      area.y = widget->allocation.y;
-      area.width = widget->allocation.width;
-      area.height = widget->allocation.height;
+      area.x = page->tab_label->allocation.x - 1;
+      area.y = page->tab_label->allocation.y - 1;
+      area.width = page->tab_label->allocation.width + 2;
+      area.height = page->tab_label->allocation.height + 2;
 
-      gtk_notebook_draw_tab(GTK_NOTEBOOK(widget), page, &area);
+      gtk_notebook_draw_tab (GTK_NOTEBOOK (widget), page, &area);
     }
 }
 
@@ -1802,7 +1802,34 @@
   g_return_if_fail (notebook != NULL);
   g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
 
-  gtk_notebook_expose_tabs(notebook);
+  if (GTK_WIDGET_DRAWABLE (notebook) && notebook->show_tabs) 
+    {
+      GdkRectangle area;
+
+      if (notebook->focus_tab)
+       {
+         GtkNotebookPage *page;
+
+         page = notebook->focus_tab->data;
+
+         area.x = page->tab_label->allocation.x - 1;
+         area.y = page->tab_label->allocation.y - 1;
+         area.width = page->tab_label->allocation.width + 2;
+         area.height = page->tab_label->allocation.height + 2;
+
+         gtk_notebook_draw_tab (notebook, page, &area);
+       }
+
+      if (old_page)
+       {
+         area.x = old_page->tab_label->allocation.x - 1;
+         area.y = old_page->tab_label->allocation.y - 1;
+         area.width = old_page->tab_label->allocation.width + 2;
+         area.height = old_page->tab_label->allocation.height + 2;
+
+         gtk_notebook_draw_tab (notebook, old_page, &area);
+       }
+    }
 }
 
 static gint
@@ -2235,8 +2262,7 @@
                          page_area.width, page_area.height,
                          gap_side);
       if ((GTK_WIDGET_HAS_FOCUS (widget)) &&
-         notebook->focus_tab && (notebook->focus_tab->data == page) &&
-         (page))
+         notebook->focus_tab && (notebook->focus_tab->data == page))
        {
          gtk_paint_focus (widget->style, widget->window,
                           area, widget, "tab",



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