r16051 - gnucash/trunk/src/gnome - When saving a check format, query the user for the title to write into

David Hampton hampton at cvs.gnucash.org
Sat May 5 17:46:07 EDT 2007


Author: hampton
Date: 2007-05-05 17:46:06 -0400 (Sat, 05 May 2007)
New Revision: 16051
Trac: http://svn.gnucash.org/trac/changeset/16051

Modified:
   gnucash/trunk/src/gnome/dialog-print-check.c
   gnucash/trunk/src/gnome/glade/print.glade
Log:
When saving a check format, query the user for the title to write into
that format.  Fixed #434409.


Modified: gnucash/trunk/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-print-check.c	2007-05-05 21:08:41 UTC (rev 16050)
+++ gnucash/trunk/src/gnome/dialog-print-check.c	2007-05-05 21:46:06 UTC (rev 16051)
@@ -125,6 +125,7 @@
 void gnc_print_check_format_changed(GtkComboBox *widget, PrintCheckDialog * pcd);
 void gnc_print_check_position_changed(GtkComboBox *widget, PrintCheckDialog * pcd);
 void gnc_print_check_save_button_clicked(GtkButton *button, PrintCheckDialog *pcd);
+void gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button);
 
 
 /** This enum defines the types of items that gnucash knows how to
@@ -496,7 +497,9 @@
 /** Save all of the information from the custom check dialog into a check
  *  description file. */
 static void
-pcd_save_custom_data(PrintCheckDialog *pcd, gchar *filename)
+pcd_save_custom_data(PrintCheckDialog *pcd,
+                     const gchar *filename,
+                     const gchar *title)
 {
     GKeyFile *key_file;
     GError *error = NULL;
@@ -512,8 +515,7 @@
     guid_new(&guid);
     guid_to_string_buff(&guid, buf);
     g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_GUID, buf);
-    g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE,
-                          _("Custom Check"));
+    g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE, title);
     g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, FALSE);
     g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, FALSE);
     g_key_file_set_double(key_file, KF_GROUP_TOP, KF_KEY_ROTATION,
@@ -547,17 +549,51 @@
 }
 
 
+/* Make the OK button sensitive iff a title has been entered. */
+void
+gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button)
+{
+  const gchar *text;
+  gboolean sensitive;
+
+  text = gtk_entry_get_text(GTK_ENTRY(editable));
+  sensitive = text && *text;
+  gtk_widget_set_sensitive(ok_button, sensitive);
+}
+
+
 /** This function is called when the user clicks the "save format" button in
  *  the check printing dialog.  It presents another dialog to the user to get
  *  the filename for saving the data. */
 void
-gnc_print_check_save_button_clicked(GtkButton *button, PrintCheckDialog *pcd)
+gnc_print_check_save_button_clicked(GtkButton *unused, PrintCheckDialog *pcd)
 {
     GtkFileChooser *chooser;
     GtkFileFilter *filter;
-    GtkWidget *dialog;
-    gchar *check_dir, *filename;
+    GtkWidget *dialog, *entry, *button;
+    GladeXML *xml;
+    gchar *check_dir, *filename, *title;
 
+    /* Get a title for the new check format. */
+    xml = gnc_glade_xml_new ("print.glade", "Format Title Dialog");
+    dialog = glade_xml_get_widget (xml, "Format Title Dialog");
+    entry = glade_xml_get_widget (xml, "format_title");
+    button = glade_xml_get_widget (xml, "okbutton");
+    gnc_check_format_title_changed(GTK_EDITABLE(entry), button);
+    glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, pcd);
+
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pcd->dialog));
+    if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) {
+        gtk_widget_destroy(dialog);
+        g_object_unref(xml);
+        return;
+    }
+
+    /* Now get the filename. */
+    title = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+    gtk_widget_destroy (dialog);
+    g_object_unref(xml);
+
     dialog = gtk_file_chooser_dialog_new(_("Save Check Description"),
                                          GTK_WINDOW(pcd->dialog),
                                          GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -581,13 +617,15 @@
     gtk_file_filter_add_pattern(filter, "*");
     gtk_file_chooser_add_filter(chooser, filter);
 
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pcd->dialog));
     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
         filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-        pcd_save_custom_data(pcd, filename);
+        pcd_save_custom_data(pcd, filename, title);
         g_free(filename);
     }
 
     gtk_widget_destroy (dialog);
+    g_free(title);
 }
 
 

Modified: gnucash/trunk/src/gnome/glade/print.glade
===================================================================
--- gnucash/trunk/src/gnome/glade/print.glade	2007-05-05 21:08:41 UTC (rev 16050)
+++ gnucash/trunk/src/gnome/glade/print.glade	2007-05-05 21:46:06 UTC (rev 16051)
@@ -1088,4 +1088,115 @@
   </child>
 </widget>
 
+<widget class="GtkDialog" id="Format Title Dialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">New Check Format Title</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox7">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area7">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="cancelbutton">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-cancel</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-6</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="okbutton">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="has_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkLabel" id="label847683">
+	  <property name="visible">True</property>
+	  <property name="can_focus">True</property>
+	  <property name="label" translatable="yes">Please enter a title for the new check format.  This title will appear in the &quot;Check format&quot; selector in the Print Check dialog.</property>
+	  <property name="use_underline">False</property>
+	  <property name="use_markup">False</property>
+	  <property name="justify">GTK_JUSTIFY_LEFT</property>
+	  <property name="wrap">True</property>
+	  <property name="selectable">True</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>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkEntry" id="format_title">
+	  <property name="visible">True</property>
+	  <property name="can_focus">True</property>
+	  <property name="editable">True</property>
+	  <property name="visibility">True</property>
+	  <property name="max_length">0</property>
+	  <property name="text" translatable="yes"></property>
+	  <property name="has_frame">True</property>
+	  <property name="invisible_char">•</property>
+	  <property name="activates_default">True</property>
+	  <signal name="changed" handler="gnc_check_format_title_changed" object="okbutton" last_modification_time="Sat, 05 May 2007 20:53:21 GMT"/>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">False</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>



More information about the gnucash-changes mailing list