rpms/gtk2/F-9 print-at-local-time.patch, NONE, 1.1 gtk2.spec, 1.298, 1.299

Marek Kašík mkasik at fedoraproject.org
Fri Nov 21 07:55:42 UTC 2008


Author: mkasik

Update of /cvs/pkgs/rpms/gtk2/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv12400

Modified Files:
	gtk2.spec 
Added Files:
	print-at-local-time.patch 
Log Message:
* Fri Nov 21 2008 Marek Kasik <mkasik at redhat.com> - 2.12.12-2
- "Print at" takes local time from now.
- Resolves: #471419


print-at-local-time.patch:

--- NEW FILE print-at-local-time.patch ---
--- modules/printbackends/cups/gtkprintbackendcups.c	2008-11-20 13:20:37.000000000 +0100
+++ modules/printbackends/cups/gtkprintbackendcups.c	2008-11-20 13:51:24.000000000 +0100
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
+#include <time.h>
 
 #include <cups/cups.h>
 #include <cups/language.h>
@@ -3054,6 +3055,50 @@ foreach_option_get_settings (GtkPrinterO
     gtk_print_settings_set (settings, option->name, value);
 }
 
+/* Converts local time to UTC time. Local time has to be in HH:MM format or
+ * in HH:MM:SS format.
+ * Returns a newly allocated string holding UTC time in HH:MM:SS format
+ * or NULL.
+ */
+char *
+convert_localtime_to_utctime (const char *local_time)
+{
+  struct tm local_print_time;
+  char *utc_time = NULL;
+
+  local_print_time.tm_sec = 0;
+
+  if ((local_time != NULL) &&
+      ((sscanf (local_time, "%d:%d:%d",
+                &(local_print_time.tm_hour),
+                &(local_print_time.tm_min),
+                &(local_print_time.tm_sec)) == 3) ||
+       (sscanf (local_time, "%d:%d",
+                &(local_print_time.tm_hour),
+                &(local_print_time.tm_min)) == 2)))
+    {
+      struct tm diff_time, utc_print_time;
+
+      time_t rawtime;
+      time (&rawtime);
+
+      diff_time.tm_hour = gmtime (&rawtime)->tm_hour - localtime (&rawtime)->tm_hour;
+      diff_time.tm_min = gmtime (&rawtime)->tm_min - localtime (&rawtime)->tm_min;
+      diff_time.tm_sec = gmtime (&rawtime)->tm_sec - localtime (&rawtime)->tm_sec;
+
+      utc_print_time.tm_hour = ((local_print_time.tm_hour + diff_time.tm_hour) + 24) % 24;
+      utc_print_time.tm_min = ((local_print_time.tm_min + diff_time.tm_min) + 60) % 60;
+      utc_print_time.tm_sec = ((local_print_time.tm_sec + diff_time.tm_sec) + 60) % 60;
+
+      utc_time = g_strdup_printf ("%02d:%02d:%02d",
+                                  utc_print_time.tm_hour,
+                                  utc_print_time.tm_min,
+                                  utc_print_time.tm_sec);
+    }
+
+  return utc_time;
+}
+
 static void
 cups_printer_get_settings_from_options (GtkPrinter          *printer,
 					GtkPrinterOptionSet *options,
@@ -3084,8 +3129,21 @@ cups_printer_get_settings_from_options (
 
       print_at = gtk_print_settings_get (settings, "print-at");
       print_at_time = gtk_print_settings_get (settings, "print-at-time");
+
       if (strcmp (print_at, "at") == 0)
-	gtk_print_settings_set (settings, "cups-job-hold-until", print_at_time);
+        {
+          gchar *utc_time = NULL;
+          
+          utc_time = convert_localtime_to_utctime (print_at_time);
+
+          if (utc_time != NULL)
+            {
+              gtk_print_settings_set (settings, "cups-job-hold-until", utc_time);
+              g_free (utc_time);
+            }
+          else
+            gtk_print_settings_set (settings, "cups-job-hold-until", print_at_time);
+        }
       else if (strcmp (print_at, "on-hold") == 0)
 	gtk_print_settings_set (settings, "cups-job-hold-until", "indefinite");
     }


Index: gtk2.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gtk2/F-9/gtk2.spec,v
retrieving revision 1.298
retrieving revision 1.299
diff -u -r1.298 -r1.299
--- gtk2.spec	13 Sep 2008 05:04:06 -0000	1.298
+++ gtk2.spec	21 Nov 2008 07:55:11 -0000	1.299
@@ -16,7 +16,7 @@
 Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X
 Name: gtk2
 Version: %{base_version}
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: LGPLv2+
 Group: System Environment/Libraries
 Source: http://download.gnome.org/sources/gtk+/2.12/gtk+-%{version}.tar.bz2
@@ -51,6 +51,9 @@
 
 Patch14: empty-modmap-crash.patch
 
+# https://bugzilla.redhat.com/show_bug.cgi?id=471419
+Patch15: print-at-local-time.patch
+
 BuildRequires: atk-devel >= %{atk_version}
 BuildRequires: pango-devel >= %{pango_version}
 BuildRequires: glib2-devel >= %{glib2_version}
@@ -132,6 +135,7 @@
 %patch4 -p1 -b .im-setting
 %patch10 -p0 -b .printer-state
 %patch13 -p0 -b .printer-paper-size
+%patch15 -p0 -b .print-at-local-time
 
 for i in config.guess config.sub ; do
   test -f %{_datadir}/libtool/$i && cp %{_datadir}/libtool/$i .
@@ -324,6 +328,10 @@
 %{_datadir}/gtk-2.0
 
 %changelog
+* Fri Nov 21 2008 Marek Kasik <mkasik at redhat.com> - 2.12.12-2
+- "Print at" takes local time from now.
+- Resolves: #471419
+
 * Sat Sep 13 2008 Matthias Clasen <mclasen at redhat.com> - 2.12.12-1
 - Update to 2.12.12
 




More information about the fedora-extras-commits mailing list