]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpapersize.c
GtkEntry: Sanity check the end_pos value in _get_display_text()
[~andy/gtk] / gtk / gtkpapersize.c
index 8fbcddb373fbeb4e952215eaf4e5e1a09c1d7f00..1ab622e1949135b67345cb7d45e34f2b0809bebc 100644 (file)
@@ -14,9 +14,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 #include "gtkprintoperation.h"  /* for GtkPrintError */
 #include "gtkintl.h"
 
+#ifdef G_OS_UNIX                /* _gtk_load_custom_papers() only on Unix so far  */
+#include "gtkcustompaperunixdialog.h"
+#endif
+
 #include "paper_names_offsets.c"
 
 
@@ -350,7 +352,7 @@ gtk_paper_size_new_from_ppd (const gchar *ppd_name,
  * @display_name: the human-readable name
  * @width: the paper width, in units of @unit
  * @height: the paper height, in units of @unit
- * @unit: the unit for @width and @height
+ * @unit: the unit for @width and @height. not %GTK_UNIT_NONE.
  *
  * Creates a new #GtkPaperSize object with the
  * given parameters.
@@ -369,7 +371,7 @@ gtk_paper_size_new_custom (const gchar *name,
 {
   GtkPaperSize *size;
   g_return_val_if_fail (name != NULL, NULL);
-  g_return_val_if_fail (unit != GTK_UNIT_PIXEL, NULL);
+  g_return_val_if_fail (unit != GTK_UNIT_NONE, NULL);
 
   size = g_slice_new0 (GtkPaperSize);
 
@@ -456,8 +458,6 @@ gtk_paper_size_is_equal (GtkPaperSize *size1,
                  gtk_paper_size_get_name (size2)) == 0;
 }
 
-GList * _gtk_load_custom_papers (void);
-
 /**
  * gtk_paper_size_get_paper_sizes:
  * @include_custom: whether to include custom paper sizes
@@ -490,8 +490,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
           list = g_list_prepend (list, gtk_paper_size_copy (size));
         }
 
-      g_list_foreach (page_setups, (GFunc) g_object_unref, NULL);
-      g_list_free (page_setups);
+      g_list_free_full (page_setups, g_object_unref);
     }
 #endif
   for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)
@@ -516,7 +515,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
  *
  * Since: 2.10
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_paper_size_get_name (GtkPaperSize *size)
 {
   if (size->name)
@@ -535,7 +534,7 @@ gtk_paper_size_get_name (GtkPaperSize *size)
  *
  * Since: 2.10
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_paper_size_get_display_name (GtkPaperSize *size)
 {
   const gchar *display_name;
@@ -560,7 +559,7 @@ gtk_paper_size_get_display_name (GtkPaperSize *size)
  *
  * Since: 2.10
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_paper_size_get_ppd_name (GtkPaperSize *size)
 {
   if (size->ppd_name)
@@ -573,7 +572,7 @@ gtk_paper_size_get_ppd_name (GtkPaperSize *size)
 /**
  * gtk_paper_size_get_width:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the paper width of the #GtkPaperSize, in
  * units of @unit.
@@ -592,7 +591,7 @@ gtk_paper_size_get_width (GtkPaperSize *size,
 /**
  * gtk_paper_size_get_height:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the paper height of the #GtkPaperSize, in
  * units of @unit.
@@ -660,7 +659,7 @@ gtk_paper_size_set_size (GtkPaperSize *size,
  *
  * Since: 2.10
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_paper_size_get_default (void)
 {
   char *locale, *freeme = NULL;
@@ -720,7 +719,7 @@ gtk_paper_size_get_default (void)
 /**
  * gtk_paper_size_get_default_top_margin:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the default top margin for the #GtkPaperSize.
  *
@@ -741,7 +740,7 @@ gtk_paper_size_get_default_top_margin (GtkPaperSize *size,
 /**
  * gtk_paper_size_get_default_bottom_margin:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the default bottom margin for the #GtkPaperSize.
  *
@@ -770,7 +769,7 @@ gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size,
 /**
  * gtk_paper_size_get_default_left_margin:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the default left margin for the #GtkPaperSize.
  *
@@ -791,7 +790,7 @@ gtk_paper_size_get_default_left_margin (GtkPaperSize *size,
 /**
  * gtk_paper_size_get_default_right_margin:
  * @size: a #GtkPaperSize object
- * @unit: the unit for the return value
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
  *
  * Gets the default right margin for the #GtkPaperSize.
  *
@@ -820,19 +819,21 @@ gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
  * @key_file.
  *
  * Returns: a new #GtkPaperSize object with the restored
- *          paper size, or %NULL if an error occurred.
+ *     paper size, or %NULL if an error occurred
  *
  * Since: 2.12
  */
 GtkPaperSize *
-gtk_paper_size_new_from_key_file (GKeyFile    *key_file,
-                                  const gchar *group_name,
-                                  GError     **error)
+gtk_paper_size_new_from_key_file (GKeyFile     *key_file,
+                                  const gchar  *group_name,
+                                  GError      **error)
 {
   GtkPaperSize *paper_size = NULL;
-  char *name = NULL, *ppd_name = NULL, *display_name = NULL, *freeme = NULL;
+  gchar *name = NULL;
+  gchar *ppd_name = NULL;
+  gchar *display_name = NULL;
+  gchar *freeme = NULL;
   gdouble width, height;
-  gboolean retval = TRUE;
   GError *err = NULL;
 
   g_return_val_if_fail (key_file != NULL, NULL);
@@ -845,7 +846,6 @@ gtk_paper_size_new_from_key_file (GKeyFile    *key_file,
                            GTK_PRINT_ERROR,
                            GTK_PRINT_ERROR_INVALID_FILE,
                            _("Not a valid page setup file"));
-      retval = FALSE;
       goto out;
     }
 
@@ -854,7 +854,6 @@ gtk_paper_size_new_from_key_file (GKeyFile    *key_file,
   if (err != NULL) \
     {\
       g_propagate_error (error, err);\
-      retval = FALSE;\
       goto out;\
     }
 
@@ -887,9 +886,9 @@ gtk_paper_size_new_from_key_file (GKeyFile    *key_file,
                            GTK_PRINT_ERROR,
                            GTK_PRINT_ERROR_INVALID_FILE,
                            _("Not a valid page setup file"));
-      retval = FALSE;
       goto out;
     }
+
   g_assert (paper_size != NULL);
 
 out: