r15774 - gnucash/trunk/src - Allow the user to specify the maximum width of the page labels in the

David Hampton hampton at cvs.gnucash.org
Sun Apr 1 23:42:22 EDT 2007


Author: hampton
Date: 2007-04-01 23:42:21 -0400 (Sun, 01 Apr 2007)
New Revision: 15774
Trac: http://svn.gnucash.org/trac/changeset/15774

Modified:
   gnucash/trunk/src/gnome-utils/glade/preferences.glade
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/gnc-main-window.h
   gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
   gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
   gnucash/trunk/src/gnome/gnc-plugin-page-register.c
   gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in
Log:
Allow the user to specify the maximum width of the page labels in the
main window (#338161).  Also add a tooltip showing the account full
name to the page labels in the main window (#343239).


Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2007-04-02 03:42:21 UTC (rev 15774)
@@ -95,6 +95,7 @@
 static gboolean gnc_plugin_page_register_finish_pending (GncPluginPage *page);
 
 static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page);
+static gchar *gnc_plugin_page_register_get_long_name (GncPluginPage *plugin_page);
 
 /* Callbacks for the "Sort By" dialog */
 void gnc_plugin_page_register_sort_button_cb(GtkToggleButton *button, GncPluginPageRegister *page);
@@ -454,6 +455,10 @@
 	gnc_plugin_page_set_page_name(plugin_page, label);
 	g_free(label);
 
+	label = gnc_plugin_page_register_get_long_name(plugin_page);
+        gnc_plugin_page_set_page_long_name(plugin_page, label);
+        g_free(label);
+
 	q = gnc_ledger_display_get_query (ledger);
 	book_list = qof_query_get_books (q);
 	for (item = book_list; item; item = g_list_next(item))
@@ -1154,6 +1159,37 @@
 	return g_strdup(_("unknown"));
 }
 
+static gchar *
+gnc_plugin_page_register_get_long_name (GncPluginPage *plugin_page)
+{
+	GncPluginPageRegisterPrivate *priv;
+	GNCLedgerDisplayType ledger_type;
+  	GNCLedgerDisplay *ld;
+	SplitRegister *reg;
+	Account *leader;
+
+	g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), _("unknown"));
+
+	priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page);
+	ld = priv->ledger;
+	reg = gnc_ledger_display_get_split_register (ld);
+	ledger_type = gnc_ledger_display_type (ld);
+	leader = gnc_ledger_display_leader (ld);
+
+	switch (ledger_type) {
+	 case LD_SINGLE:
+	  return g_strdup(xaccAccountGetFullName (leader));
+
+	 case LD_SUBACCOUNT:
+	  return g_strdup_printf("%s+", xaccAccountGetFullName (leader));
+
+	 default:
+	  break;
+	}
+
+        return NULL;
+}
+
 /************************************************************/
 /*                     "Sort By" Dialog                     */
 /************************************************************/

Modified: gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in
===================================================================
--- gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in	2007-04-02 03:42:21 UTC (rev 15774)
@@ -185,6 +185,23 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/gnucash/general/tab_width</key>
+      <applyto>/apps/gnucash/general/tab_width</applyto>
+      <owner>gnucash</owner>
+      <type>float</type>
+      <default>30.0</default>
+      <locale name="C">
+        <short>Width of notebook tabs</short>
+        <long>
+	  This key specifies the maximum width of notebook tabs.
+	  If the text in the tab is longer than this value (the test
+	  is approximate) then the tab label will have the middle cut
+	  and replaced with an ellipsis.
+	</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/gnucash/general/currency_choice</key>
       <applyto>/apps/gnucash/general/currency_choice</applyto>
       <owner>gnucash</owner>

Modified: gnucash/trunk/src/gnome-utils/glade/preferences.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/glade/preferences.glade	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome-utils/glade/preferences.glade	2007-04-02 03:42:21 UTC (rev 15774)
@@ -3457,7 +3457,7 @@
 	    <widget class="GtkTable" id="table5">
 	      <property name="border_width">6</property>
 	      <property name="visible">True</property>
-	      <property name="n_rows">19</property>
+	      <property name="n_rows">20</property>
 	      <property name="n_columns">4</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">0</property>
@@ -3478,7 +3478,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">8</property>
 		  <property name="bottom_attach">9</property>
 		  <property name="x_padding">12</property>
@@ -3503,7 +3503,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">7</property>
 		  <property name="bottom_attach">8</property>
 		  <property name="x_padding">12</property>
@@ -3528,7 +3528,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">6</property>
 		  <property name="bottom_attach">7</property>
 		  <property name="x_padding">12</property>
@@ -3553,7 +3553,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">5</property>
 		  <property name="bottom_attach">6</property>
 		  <property name="x_padding">12</property>
@@ -3578,7 +3578,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">4</property>
 		  <property name="bottom_attach">5</property>
 		  <property name="x_padding">12</property>
@@ -3607,7 +3607,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">3</property>
 		  <property name="bottom_attach">4</property>
 		  <property name="x_options">fill</property>
@@ -3635,7 +3635,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">0</property>
 		  <property name="bottom_attach">1</property>
 		  <property name="x_options">fill</property>
@@ -3685,7 +3685,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">1</property>
 		  <property name="bottom_attach">2</property>
 		  <property name="x_padding">12</property>
@@ -3708,7 +3708,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">12</property>
 		  <property name="bottom_attach">13</property>
 		  <property name="x_padding">12</property>
@@ -3738,8 +3738,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">13</property>
-		  <property name="bottom_attach">14</property>
+		  <property name="top_attach">14</property>
+		  <property name="bottom_attach">15</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -3765,9 +3765,9 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">14</property>
-		  <property name="bottom_attach">15</property>
+		  <property name="right_attach">4</property>
+		  <property name="top_attach">15</property>
+		  <property name="bottom_attach">16</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -3788,9 +3788,9 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">15</property>
-		  <property name="bottom_attach">16</property>
+		  <property name="right_attach">4</property>
+		  <property name="top_attach">16</property>
+		  <property name="bottom_attach">17</property>
 		  <property name="x_padding">12</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
@@ -3813,9 +3813,9 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">16</property>
-		  <property name="bottom_attach">17</property>
+		  <property name="right_attach">4</property>
+		  <property name="top_attach">17</property>
+		  <property name="bottom_attach">18</property>
 		  <property name="x_padding">12</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
@@ -3838,9 +3838,9 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">17</property>
-		  <property name="bottom_attach">18</property>
+		  <property name="right_attach">4</property>
+		  <property name="top_attach">18</property>
+		  <property name="bottom_attach">19</property>
 		  <property name="x_padding">12</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
@@ -3863,9 +3863,9 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">18</property>
-		  <property name="bottom_attach">19</property>
+		  <property name="right_attach">4</property>
+		  <property name="top_attach">19</property>
+		  <property name="bottom_attach">20</property>
 		  <property name="x_padding">12</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
@@ -3903,7 +3903,7 @@
 	      <child>
 		<widget class="GtkLabel" id="label113">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">&lt;b&gt;Close Button&lt;/b&gt;</property>
+		  <property name="label" translatable="yes">&lt;b&gt;Tabs&lt;/b&gt;</property>
 		  <property name="use_underline">False</property>
 		  <property name="use_markup">True</property>
 		  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -3920,7 +3920,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">10</property>
 		  <property name="bottom_attach">11</property>
 		  <property name="x_options">fill</property>
@@ -3943,7 +3943,7 @@
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">4</property>
 		  <property name="top_attach">11</property>
 		  <property name="bottom_attach">12</property>
 		  <property name="x_padding">12</property>
@@ -3951,6 +3951,108 @@
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
+
+	      <child>
+		<widget class="GtkAlignment" id="alignment9">
+		  <property name="visible">True</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xscale">1</property>
+		  <property name="yscale">1</property>
+		  <property name="top_padding">0</property>
+		  <property name="bottom_padding">0</property>
+		  <property name="left_padding">12</property>
+		  <property name="right_padding">0</property>
+
+		  <child>
+		    <widget class="GtkLabel" id="label117">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Width:</property>
+		      <property name="use_underline">True</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>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">13</property>
+		  <property name="bottom_attach">14</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options">fill</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkHBox" id="hbox3">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">0</property>
+
+		  <child>
+		    <widget class="GtkSpinButton" id="gconf/general/tab_width">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="climb_rate">1</property>
+		      <property name="digits">0</property>
+		      <property name="numeric">True</property>
+		      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		      <property name="snap_to_ticks">False</property>
+		      <property name="wrap">False</property>
+		      <property name="adjustment">30 1 100 1 10 10</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label118">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">characters</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">3</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="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">13</property>
+		  <property name="bottom_attach">14</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options">fill</property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
 	      <property name="tab_expand">False</property>

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2007-04-02 03:42:21 UTC (rev 15774)
@@ -79,10 +79,12 @@
 #define PLUGIN_PAGE_LABEL "plugin-page"
 
 #define PLUGIN_PAGE_CLOSE_BUTTON "close-button"
+#define PLUGIN_PAGE_TAB_LABEL    "label"
 
 #define KEY_SHOW_CLOSE_BUTTON	"tab_close_buttons"
 #define KEY_TAB_NEXT_RECENT	"tab_next_recent"
 #define KEY_TAB_POSITION	"tab_position"
+#define KEY_TAB_WIDTH           "tab_width"
 
 #define GNC_MAIN_WINDOW_NAME "GncMainWindow"
 
@@ -392,6 +394,11 @@
 };
 
 
+/* This data structure holds the tooltops for all notebook tabs.
+ * Typically these are used to provide the full path of a register
+ * page. */
+static GtkTooltips *tips = NULL;
+
 /************************************************************
  *                                                          *
  ************************************************************/
@@ -419,6 +426,29 @@
 } GncMainWindowSaveData;
 
 
+/*  Iterator function to walk all pages in all windows, calling the
+ *  specified function for each page. */
+void
+gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data)
+{
+  GncMainWindowPrivate *priv;
+  GncMainWindow *window;
+  GncPluginPage *page;
+  GList *w, *p;
+
+  ENTER(" ");
+  for (w = active_windows; w; w = g_list_next(w)) {
+    window = w->data;
+    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
+    for (p = priv->installed_pages; p; p = g_list_next(p)) {
+      page = p->data;
+      fn(page, user_data);
+    }
+  }
+  LEAVE(" ");
+}
+
+
 /** Restore a single page to a window.  This function calls a page
  *  specific function to create the actual page.  It then handles all
  *  the common tasks such as insuring the page is installed into a
@@ -1445,9 +1475,10 @@
  *  or not the close button should be visible.
  */
 static void
-gnc_main_window_update_tabs_one_page (GncPluginPage *page,
-				      gboolean *new_value)
+gnc_main_window_update_tab_close_one_page (GncPluginPage *page,
+                                           gpointer user_data)
 {
+  gboolean *new_value = user_data;
   GtkWidget * close_button;
 
   ENTER("page %p, visible %d", page, *new_value);
@@ -1465,52 +1496,88 @@
 }
 
 
-/** Show/hide the close box on all pages in a given window.  This
- *  function calls the gnc_main_window_update_tabs_one_page() for each
- *  page in the window.
+/** Show/hide the close box on all pages in all windows.  This function
+ *  calls gnc_main_window_update_tab_close() for each plugin page in the
+ *  application.
  *
  *  @internal
  *
- *  @param window The GncMainWindow whose notebook tabs should be
- *  updated.
+ *  @param entry A pointer to the GConfEntry which describes the new
+ *  state of whether close buttons should be visible on notebook tabs.
  *
- *  @param new_value A pointer to the boolean that indicates whether
- *  or not the close button should be visible.
+ *  @param user_data Unused.
  */
 static void
-gnc_main_window_update_tabs_one_window (GncMainWindow *window, gboolean *new_value)
+gnc_main_window_update_tab_close (GConfEntry *entry, gpointer user_data)
 {
-  GncMainWindowPrivate *priv;
+  gboolean new_value;
 
-  ENTER("window %p, visible %d", window, *new_value);
-  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
-  g_list_foreach(priv->installed_pages,
-		 (GFunc)gnc_main_window_update_tabs_one_page,
-		 new_value);
+  ENTER(" ");
+  new_value = gconf_value_get_bool(entry->value);
+  gnc_main_window_foreach_page(
+		 gnc_main_window_update_tab_close_one_page,
+		 &new_value);
   LEAVE(" ");
 }
 
 
-/** Show/hide the close box on all pages in all windows.  This
- *  function calls the gnc_main_window_update_tabs_one_window() for
- *  each open window in the application.
+/** Update the width of the label in the tab of a notebook page.  This
+ *  function adjusts both the width and the ellipsize mode so that the tab
+ *  label looks correct.  The special check for a zero value handles the
+ *  case where a user hasn't set a tab width and the gconf default isn't
+ *  detected.
  *
  *  @internal
  *
+ *  @param page The GncPluginPage whose notebook tab should be updated.
+ *
+ *  @param new_value The new width of the label in the tab.
+ */
+static void
+gnc_main_window_update_tab_width_one_page (GncPluginPage *page,
+                                           gpointer user_data)
+{
+  gint *new_value = user_data;
+  GtkWidget *label;
+
+  ENTER("page %p, visible %d", page, *new_value);
+  label = g_object_get_data(G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL);
+  if (!label) {
+    LEAVE("no label");
+    return;
+  }
+
+  if (*new_value != 0) {
+    gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
+    gtk_label_set_max_width_chars(GTK_LABEL(label), *new_value);
+  } else {
+    gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_NONE);
+    gtk_label_set_max_width_chars(GTK_LABEL(label), 100);
+  }
+  LEAVE(" ");
+}
+
+
+/** Update the tab label width in all pages in all windows.  This function
+ *  calls gnc_main_window_update_tab_width() for each plugin page in the
+ *  application.
+ *
+ *  @internal
+ *
  *  @param entry A pointer to the GConfEntry which describes the new
- *  state of whether close buttons should be visible on notebook tabs.
+ *  size of the tab label width.
  *
  *  @param user_data Unused.
  */
 static void
-gnc_main_window_update_tabs (GConfEntry *entry, gpointer user_data)
+gnc_main_window_update_tab_width (GConfEntry *entry, gpointer user_data)
 {
-  gboolean new_value;
+  gint new_value;
 
   ENTER(" ");
-  new_value = gconf_value_get_bool(entry->value);
-  g_list_foreach(active_windows,
-		 (GFunc)gnc_main_window_update_tabs_one_window,
+  new_value = gconf_value_get_float(entry->value);
+  gnc_main_window_foreach_page(
+		 gnc_main_window_update_tab_width_one_page,
 		 &new_value);
   LEAVE(" ");
 }
@@ -1538,8 +1605,8 @@
   children = gtk_container_get_children(GTK_CONTAINER(tab_hbox));
   for (tmp = children; tmp; tmp = g_list_next(tmp)) {
     widget = tmp->data;
-    if (GTK_IS_LABEL(widget)) {
-      *label_p = widget;
+    if (GTK_IS_EVENT_BOX(widget)) {
+      *label_p = gtk_bin_get_child(GTK_BIN(widget));
     } else if (GTK_IS_ENTRY(widget)) {
       *entry_p = widget;
     }
@@ -1771,12 +1838,17 @@
 			G_TYPE_OBJECT);
 
 	gnc_gconf_general_register_cb (KEY_SHOW_CLOSE_BUTTON,
-				       gnc_main_window_update_tabs,
+				       gnc_main_window_update_tab_close,
 				       NULL);
+	gnc_gconf_general_register_cb (KEY_TAB_WIDTH,
+				       gnc_main_window_update_tab_width,
+				       NULL);
 	gnc_hook_add_dangler(HOOK_BOOK_SAVED,
 			     (GFunc)gnc_main_window_update_all_titles, NULL);
 	gnc_hook_add_dangler(HOOK_BOOK_OPENED,
 			     (GFunc)gnc_main_window_attach_to_book, NULL);
+
+        tips = gtk_tooltips_new();
 }
 
 
@@ -2070,10 +2142,11 @@
 {
 	GncMainWindowPrivate *priv;
 	GtkWidget *tab_hbox;
-	GtkWidget *label, *entry;
-	const gchar *icon;
+	GtkWidget *label, *entry, *event_box;
+	const gchar *icon, *text;
 	GtkWidget *image;
 	GList *tmp;
+	gint width;
 
 	ENTER("window %p, page %p", window, page);
 
@@ -2112,9 +2185,15 @@
 	/*
 	 * The page tab.
 	 */
+        width = gnc_gconf_get_float(GCONF_GENERAL, KEY_TAB_WIDTH, NULL);
 	icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
 	label = gtk_label_new (gnc_plugin_page_get_page_name(page));
+        if (width != 0) {
+          gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
+          gtk_label_set_max_width_chars(GTK_LABEL(label), width);
+        }
 	gtk_widget_show (label);
+        g_object_set_data(G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
 
 	tab_hbox = gtk_hbox_new (FALSE, 6);
 	gtk_widget_show (tab_hbox);
@@ -2125,8 +2204,17 @@
 		gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
 	} 
 
-	gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
-  
+        event_box = gtk_event_box_new();
+        gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box), FALSE);
+        gtk_widget_show(event_box);
+        gtk_container_add(GTK_CONTAINER(event_box), label);
+	gtk_box_pack_start (GTK_BOX (tab_hbox), event_box, TRUE, TRUE, 0);
+
+        text = gnc_plugin_page_get_page_long_name(page);
+        if (text) {
+          gtk_tooltips_set_tip(tips, event_box, text, NULL);
+        }
+
 	entry = gtk_entry_new();
 	gtk_widget_hide (entry);
 	gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.h	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.h	2007-04-02 03:42:21 UTC (rev 15774)
@@ -76,6 +76,7 @@
 } GncMainWindowActionData;
 
 typedef void (*GncMainWindowFunc) (GncMainWindow *window, GncPluginPage *page);
+typedef void (*GncMainWindowPageFunc) (GncPluginPage *page, gpointer user_data);
 
 /* function prototypes */
 
@@ -127,6 +128,17 @@
 void gnc_main_window_close_page (GncPluginPage *page);
 
 
+/*  Iterator function to walk all pages in all windows, calling the
+ *  specified function for each page.
+ *
+ *  @param entry A pointer to the function to be called.
+ *
+ *  @param user_data A data pointer passed to each call of the function.
+ */
+void gnc_main_window_foreach_page (GncMainWindowPageFunc fn,
+                                   gpointer user_data);
+
+
 /** Retrieve a pointer to the page that is currently at the front of
  *  the specified window.  Any plugin that needs to manipulate its
  *  menus based upon the currently selected menu page should connect

Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.c	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.c	2007-04-02 03:42:21 UTC (rev 15774)
@@ -95,6 +95,7 @@
 	gboolean use_new_window;
 
 	gchar *page_name;
+	gchar *page_long_name;
 	gchar *uri;
 	gchar *statusbar_text;
 } GncPluginPagePrivate;
@@ -769,6 +770,38 @@
 }
 
 
+/*  Retrieve the long name of this page.  This is the string used in
+ *  the tooltip that is attached to the pate name in the notebook
+ *  tab. */
+const gchar *
+gnc_plugin_page_get_page_long_name (GncPluginPage *page)
+{
+  GncPluginPagePrivate *priv;
+
+  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+
+  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+  return priv->page_long_name;
+}
+
+
+/*  Set the long name of this page.  This is the string used in the
+ *  tooltip that is attached to the pate name in the notebook tab. */
+void
+gnc_plugin_page_set_page_long_name (GncPluginPage *page, const gchar *name)
+{
+  GncPluginPagePrivate *priv;
+  GncPluginPageClass *klass;
+
+  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+
+  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+  if (priv->page_long_name)
+    g_free(priv->page_long_name);
+  priv->page_long_name = g_strdup(name);
+}
+
+
 /*  Retrieve the Uniform Resource Identifier for this page. */
 const gchar *
 gnc_plugin_page_get_uri (GncPluginPage *page)

Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.h	2007-04-01 22:18:50 UTC (rev 15773)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.h	2007-04-02 03:42:21 UTC (rev 15774)
@@ -350,6 +350,28 @@
 void gnc_plugin_page_set_page_name (GncPluginPage *page, const char *name);
 
 
+/** Retrieve the long name of this page.  This is the string used in
+ *  the tooltip that is attached to the pate name in the notebook
+ *  tab.
+ *
+ *  @param page The page whose name should be retrieved.
+ *
+ *  @return The page's name.  This string is owned by the page and
+ *  should not be freed by the caller.
+ */
+const gchar *gnc_plugin_page_get_page_long_name (GncPluginPage *page);
+
+
+/** Set the long name of this page.  This is the string used in the
+ *  tooltip that is attached to the pate name in the notebook tab.
+ *
+ *  @param page The page whose name should be set.
+ *
+ *  @param name The new string for the name.
+ */
+void gnc_plugin_page_set_page_long_name (GncPluginPage *page, const char *name);
+
+
 /** Retrieve the Uniform Resource Identifier for this page.
  *
  *  @param page The page whose URI should be retrieved.



More information about the gnucash-changes mailing list