[Gnucash-changes] Use a GtkComboBox in place of the deprecated GtkOptionMenu.

David Hampton hampton at cvs.gnucash.org
Wed Sep 14 02:12:25 EDT 2005


Log Message:
-----------
Use a GtkComboBox in place of the deprecated GtkOptionMenu.  Add a
choice in the combo box for the UTC time format to match the new
addition to the QofDateFormat enum.  Clean up the code slightly.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/gnome-utils:
        gnc-date-format.c
        gnc-date-format.glade
        gnc-date-format.h

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.283
retrieving revision 1.1487.2.284
diff -LChangeLog -LChangeLog -u -r1.1487.2.283 -r1.1487.2.284
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,14 @@
+2005-09-14  David Hampton  <hampton at employees.org>
+
+	* src/engine/gnc-date.[ch]: Fix function name.  Document
+	functions.
+
+	* src/gnome-utils/gnc-date-format.[ch]:
+	* src/gnome-utils/gnc-date-format.glade: Use a GtkComboBox in
+	place of the deprecated GtkOptionMenu.  Add aa choice in the combo
+	box for the UTC time format to match the new addition to the
+	QofDateFormat enum.  Clean up the code slightly.
+
 2005-09-10  Christian Stimming  <stimming at tuhh.de>
 
 	* src/import-export/hbci/dialog-hbcitrans.[hc]: Add support for
Index: gnc-date-format.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-format.h,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -Lsrc/gnome-utils/gnc-date-format.h -Lsrc/gnome-utils/gnc-date-format.h -u -r1.3.2.2 -r1.3.2.3
--- src/gnome-utils/gnc-date-format.h
+++ src/gnome-utils/gnc-date-format.h
@@ -44,16 +44,11 @@
  **/
 typedef struct {
 	GtkHBox hbox;
-
-	GtkWidget *label;
-
 	GNCDateFormatPriv *priv;
-
-	int disposed;
 } GNCDateFormat;
 
 typedef struct {
-	GtkHBoxClass parent_class;
+	GtkHBoxClass hbox_class;
 	void (*format_changed) (GNCDateFormat *gdf);
 } GNCDateFormatClass;
 
Index: gnc-date-format.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-format.c,v
retrieving revision 1.3.2.6
retrieving revision 1.3.2.7
diff -Lsrc/gnome-utils/gnc-date-format.c -Lsrc/gnome-utils/gnc-date-format.c -u -r1.3.2.6 -r1.3.2.7
--- src/gnome-utils/gnc-date-format.c
+++ src/gnome-utils/gnc-date-format.c
@@ -48,7 +48,9 @@
 };
 
 struct _GNCDateFormatPriv {
-  GtkWidget*	format_omenu;
+  GtkWidget*	format_combobox;
+
+  GtkWidget*    label;
 
   GtkWidget*	months_label;
   GtkWidget*	months_number;
@@ -62,9 +64,6 @@
   GtkWidget*	custom_entry;
 
   GtkWidget*	sample_label;
-
-  GtkWidget*	table;
-  GtkWidget*	label_box;
 };
 
 static guint date_format_signals [LAST_SIGNAL] = { 0 };
@@ -73,7 +72,6 @@
 static void gnc_date_format_init         (GNCDateFormat      *gdf);
 static void gnc_date_format_class_init   (GNCDateFormatClass *class);
 static void gnc_date_format_finalize     (GObject            *object);
-static void gnc_date_format_dispose      (GObject            *object);
 static void gnc_date_format_compute_format(GNCDateFormat *gdf);
 
 /* Used by glade_xml_signal_autoconnect_full */
@@ -128,27 +126,22 @@
 		  G_STRUCT_OFFSET (GNCDateFormatClass, format_changed),
 		  NULL,
 		  NULL,
-		  g_cclosure_marshal_VOID__POINTER,
+		  g_cclosure_marshal_VOID__VOID,
 		  G_TYPE_NONE,
 		  0);
 
-  gobject_class->dispose = gnc_date_format_dispose;
   gobject_class->finalize = gnc_date_format_finalize;
-
-  /* GtkObjectClass class->format_changed = NULL; */
 }
 
 static void
 gnc_date_format_init (GNCDateFormat *gdf)
 {
   GladeXML *xml;
-  GtkWidget *dialog;
+  GtkWidget *dialog, *table;
 
   g_return_if_fail(gdf);
   g_return_if_fail(GNC_IS_DATE_FORMAT(gdf));
 
-  gdf->disposed = FALSE;
-
   gdf->priv = g_new0(GNCDateFormatPriv, 1);
 
   /* Open up the Glade and set the signals */
@@ -156,8 +149,8 @@
   glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, gdf);
 
   /* pull in all the child widgets */
-  gdf->label = glade_xml_get_widget(xml, "widget_label");
-  gdf->priv->format_omenu = glade_xml_get_widget(xml, "format_omenu");
+  gdf->priv->label = glade_xml_get_widget(xml, "widget_label");
+  gdf->priv->format_combobox = glade_xml_get_widget(xml, "format_combobox");
 
   gdf->priv->months_label = glade_xml_get_widget(xml, "months_label");
   gdf->priv->months_number = glade_xml_get_widget(xml, "month_number_button");
@@ -172,47 +165,20 @@
 
   gdf->priv->sample_label = glade_xml_get_widget(xml, "sample_label");
 
-  gdf->priv->table = glade_xml_get_widget(xml, "date_format_table");
-  gdf->priv->label_box = glade_xml_get_widget(xml, "label_box");
-
-  /* Initialize the format menu */
-  gnc_option_menu_init_w_signal(gdf->priv->format_omenu,
-				GTK_SIGNAL_FUNC(gnc_ui_date_format_changed_cb), gdf);
-
   /* Set initial format to gnucash default */
   gnc_date_format_set_format(gdf, qof_date_format_get());
 
   /* pull in the dialog and table widgets and play the reconnect game */
   dialog = glade_xml_get_widget(xml, "GNC Date Format");
 
-  g_object_ref(G_OBJECT(gdf->priv->table));
-  gtk_container_remove(GTK_CONTAINER(dialog), gdf->priv->table);
-  gtk_container_add(GTK_CONTAINER(gdf), gdf->priv->table);
-  /* XXX: do I need to unref the table? 
-     SAE: I think so, see gnc_data_format_dispose
-   */
-  gtk_widget_destroy(dialog);
-}
-
-static void
-gnc_date_format_dispose (GObject *object)
-{
-  GNCDateFormat *gdf;
+  table = glade_xml_get_widget(xml, "date_format_table");
+  g_object_ref(G_OBJECT(table));
+  gtk_container_remove(GTK_CONTAINER(dialog), table);
+  gtk_container_add(GTK_CONTAINER(gdf), table);
+  g_object_unref(G_OBJECT(table));
 
-  g_return_if_fail(object != NULL);
-  g_return_if_fail(GNC_IS_DATE_FORMAT(object));
-
-  gdf = GNC_DATE_FORMAT(object);
-
-  if(gdf->disposed)
-    return;
-
-  gdf->disposed = TRUE;
-
-  g_object_unref(G_OBJECT(gdf->priv->table));
-
-  if (G_OBJECT_CLASS(parent_class)->dispose)
-    (* G_OBJECT_CLASS(parent_class)->dispose) (object);
+  /* Destroy the now empty window */
+  gtk_widget_destroy(dialog);
 }
 
 static void
@@ -246,15 +212,14 @@
   return gnc_date_format_new_with_label (NULL);
 }
 
-GtkWidget
-*gnc_date_format_new_without_label (void)
+GtkWidget *
+gnc_date_format_new_without_label (void)
 {
   GtkWidget *widget = gnc_date_format_new_with_label(NULL);
   GNCDateFormat *gdf = GNC_DATE_FORMAT(widget);
 
-  gtk_container_remove(GTK_CONTAINER(gdf->priv->table), gdf->priv->label_box);
-  gdf->label = NULL;
-  gtk_widget_queue_resize(gdf->priv->table);
+  gtk_widget_destroy(gdf->priv->label);
+  gdf->priv->label = NULL;
 
   return widget;
 }
@@ -276,7 +241,7 @@
   gdf = g_object_new(GNC_TYPE_DATE_FORMAT, NULL);
 
   if (label)
-    gtk_label_set_text(GTK_LABEL(gdf->label), label);
+    gtk_label_set_text(GTK_LABEL(gdf->priv->label), label);
 
   gnc_date_format_compute_format(gdf);
   return GTK_WIDGET(gdf);
@@ -288,7 +253,7 @@
   g_return_if_fail(gdf);
   g_return_if_fail(GNC_IS_DATE_FORMAT(gdf));
 
-  gtk_option_menu_set_history(GTK_OPTION_MENU(gdf->priv->format_omenu), format);
+  gtk_combo_box_set_active(GTK_COMBO_BOX(gdf->priv->format_combobox), format);
   gnc_date_format_compute_format(gdf);
 }
 
@@ -298,7 +263,7 @@
   g_return_val_if_fail (gdf, QOF_DATE_FORMAT_LOCALE);
   g_return_val_if_fail (GNC_IS_DATE_FORMAT(gdf), QOF_DATE_FORMAT_LOCALE);
 
-  return gnc_option_menu_get_active(gdf->priv->format_omenu);
+  return gtk_combo_box_get_active(GTK_COMBO_BOX(gdf->priv->format_combobox));
 }
 
 void
@@ -452,7 +417,8 @@
   g_return_if_fail(gdf);
   g_return_if_fail(GNC_IS_DATE_FORMAT(gdf));
 
-  sel_option = gnc_option_menu_get_active(gdf->priv->format_omenu);
+  sel_option =
+    gtk_combo_box_get_active(GTK_COMBO_BOX(gdf->priv->format_combobox));
 
   switch (sel_option) {
    case QOF_DATE_FORMAT_CUSTOM:
@@ -462,7 +428,8 @@
     break;
 
    case QOF_DATE_FORMAT_LOCALE:
-    format = g_strdup(qof_date_format_get_string(QOF_DATE_FORMAT_LOCALE));
+   case QOF_DATE_FORMAT_UTC:
+    format = g_strdup(qof_date_format_get_string(sel_option));
     enable_year = enable_month = check_modifiers = enable_custom = FALSE;
     break;
 
@@ -488,7 +455,7 @@
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gdf->priv->months_number))) {
       format = g_strdup(qof_date_format_get_string(sel_option));
     } else {
-      format = g_strdup(qof_date_format_get_string(sel_option));
+      format = g_strdup(qof_date_text_format_get_string(sel_option));
       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gdf->priv->months_name))) {
 	c = strchr(format, 'b');
 	if (c)
Index: gnc-date-format.glade
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-format.glade,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -Lsrc/gnome-utils/gnc-date-format.glade -Lsrc/gnome-utils/gnc-date-format.glade -u -r1.1.4.3 -r1.1.4.4
--- src/gnome-utils/gnc-date-format.glade
+++ src/gnome-utils/gnc-date-format.glade
@@ -295,76 +295,6 @@
       </child>
 
       <child>
-	<widget class="GtkOptionMenu" id="format_omenu">
-	  <property name="visible">True</property>
-	  <property name="can_focus">True</property>
-	  <property name="history">0</property>
-
-	  <child internal-child="menu">
-	    <widget class="GtkMenu" id="convertwidget1">
-	      <property name="visible">True</property>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget2">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">US (12/31/2001)</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget3">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">UK (31/12/2001)</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget4">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Europe (31.12.2001)</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget5">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">ISO (2001-12-31)</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget6">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Locale</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkMenuItem" id="convertwidget7">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Custom</property>
-		  <property name="use_underline">True</property>
-		</widget>
-	      </child>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="left_attach">1</property>
-	  <property name="right_attach">3</property>
-	  <property name="top_attach">0</property>
-	  <property name="bottom_attach">1</property>
-	  <property name="x_options">fill</property>
-	  <property name="y_options"></property>
-	</packing>
-      </child>
-
-      <child>
 	<widget class="GtkHBox" id="label_box">
 	  <property name="visible">True</property>
 	  <property name="homogeneous">False</property>
@@ -392,24 +322,7 @@
 	  </child>
 
 	  <child>
-	    <widget class="GtkLabel" id="label9">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes"></property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</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>
-	    </widget>
-	    <packing>
-	      <property name="padding">0</property>
-	      <property name="expand">False</property>
-	      <property name="fill">False</property>
-	    </packing>
+	    <placeholder/>
 	  </child>
 	</widget>
 	<packing>
@@ -421,6 +334,29 @@
 	  <property name="y_options"></property>
 	</packing>
       </child>
+
+      <child>
+	<widget class="GtkComboBox" id="format_combobox">
+	  <property name="visible">True</property>
+	  <property name="items" translatable="yes">US (12/31/2001)
+UK (31/12/2001)
+Europe (31.12.2001)
+ISO (2001-12-31)
+UTC
+Locale
+Custom
+</property>
+	  <signal name="changed" handler="gnc_ui_date_format_changed_cb" last_modification_time="Wed, 14 Sep 2005 05:03:24 GMT"/>
+	</widget>
+	<packing>
+	  <property name="left_attach">1</property>
+	  <property name="right_attach">3</property>
+	  <property name="top_attach">0</property>
+	  <property name="bottom_attach">1</property>
+	  <property name="x_options">fill</property>
+	  <property name="y_options">fill</property>
+	</packing>
+      </child>
     </widget>
   </child>
 </widget>


More information about the gnucash-changes mailing list