X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-font-selection-dialog.c;h=6d773217eb437bc085e292e22093c5aaf9fdd69b;hb=db9685e21af93630b100473c49d066de0ad3691f;hp=a5e1c218e51aa6064c69d7f535902992b40d7fe6;hpb=dd1a98bbfb562dbc18278a0ba220c64637eefc98;p=hildon diff --git a/src/hildon-font-selection-dialog.c b/src/hildon-font-selection-dialog.c index a5e1c21..6d77321 100644 --- a/src/hildon-font-selection-dialog.c +++ b/src/hildon-font-selection-dialog.c @@ -31,27 +31,22 @@ * size, style, etc. Users can also preview text in the selected font. */ +#undef HILDON_DISABLE_DEPRECATED + #ifdef HAVE_CONFIG_H #include #endif +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include #include + #include "hildon-font-selection-dialog.h" #include "hildon-caption.h" #include "hildon-color-button.h" -#include #include "hildon-font-selection-dialog-private.h" /* These are what we use as the standard font sizes, for the size list */ @@ -211,7 +206,7 @@ hildon_font_selection_dialog_get_property (GObject *object, GParamSpec *pspec) { gint i; - GdkColor *color = NULL; + GdkColor color; HildonFontSelectionDialogPrivate *priv = HILDON_FONT_SELECTION_DIALOG_GET_PRIVATE(object); @@ -255,12 +250,9 @@ hildon_font_selection_dialog_get_property (GObject *object, break; case PROP_COLOR: - color = g_new (GdkColor, 1); hildon_color_button_get_color - (HILDON_COLOR_BUTTON (priv->font_color_button), color); - g_value_set_boxed (value, (gconstpointer) color); - if(color != NULL) - gdk_color_free (color); + (HILDON_COLOR_BUTTON (priv->font_color_button), &color); + g_value_set_boxed (value, (gconstpointer) &color); break; case PROP_COLOR_SET: @@ -776,10 +768,6 @@ hildon_font_selection_dialog_init (HildonFontSelectionDialog *font fontseldiag); gtk_widget_show(preview_button); - gtk_dialog_add_button (GTK_DIALOG (fontseldiag), - _("ecdg_bd_font_dialog_cancel"), - GTK_RESPONSE_CANCEL); - /*Set default preview text*/ priv->preview_text = g_strdup (_("ecdg_fi_preview_font_preview_text")); @@ -892,6 +880,8 @@ hildon_font_selection_dialog_construct_notebook (HildonFontSelectionDialog *font priv->cbx_positioning, NULL, HILDON_CAPTION_OPTIONAL); + g_object_unref (group); + gtk_box_pack_start (GTK_BOX (vbox_tab[2]), caption_control, FALSE, FALSE, 0); /* Populate notebook */ @@ -932,8 +922,15 @@ hildon_font_selection_dialog_finalize (GObject *object) priv = HILDON_FONT_SELECTION_DIALOG_GET_PRIVATE (fontsel); g_assert (priv); - g_free (priv->preview_text); - g_free (priv->families); + if (priv->preview_text != NULL) { + g_free (priv->preview_text); + priv->preview_text = NULL; + } + + if (priv->families != NULL) { + g_free (priv->families); + priv->families = NULL; + } if (G_OBJECT_CLASS (parent_class)->finalize) G_OBJECT_CLASS (parent_class)->finalize (object); @@ -1152,19 +1149,17 @@ hildon_font_selection_dialog_show_preview (HildonFontSelectionDialog *font preview_label = gtk_label_new (str); gtk_label_set_line_wrap (GTK_LABEL(preview_label), TRUE); - g_free (str); - str = NULL; - - gtk_container_add (GTK_CONTAINER (GTK_DIALOG(preview_dialog)->vbox), - preview_label); + if (str) + g_free (str); + str = NULL; /* set keypress handler (ESC hardkey) */ g_signal_connect (G_OBJECT (preview_dialog), "key-press-event", G_CALLBACK(hildon_font_selection_dialog_preview_key_press), NULL); - /*Set the font*/ + /* Set the font */ list = (show_ref) ? hildon_font_selection_dialog_create_attrlist (fontsel, strlen (_("ecdg_fi_preview_font_preview_reference")), strlen (priv->preview_text)) : @@ -1174,13 +1169,16 @@ hildon_font_selection_dialog_show_preview (HildonFontSelectionDialog *font &family_set, "size", &size, "size-set", &size_set, NULL); - /* FIXME: This is a slightly ugly hack to force the width of the window so that - * the whole text fits with various font sizes. It's being done in such a way, - * because of some GtkLabel wrapping issues and other mysterious bugs related to - * truncating ellipsizing. Needs a rethink in future */ + /* A smallish hack to add scrollbar when font size is really big */ - gint dialog_width = (size_set && size > 24) ? 600 : 500; - gtk_window_set_default_size (GTK_WINDOW (preview_dialog), dialog_width, -1); + if (size_set && size > 24) { + GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); + gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport (scrolled, GTK_WIDGET (preview_label)); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(preview_dialog)->vbox), GTK_WIDGET (scrolled)); + gtk_widget_set_size_request (GTK_WIDGET (scrolled), -1, 400); + } else + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(preview_dialog)->vbox), GTK_WIDGET (preview_label)); /* make reference text to have the same fontface and size */ if (family_set) @@ -1188,9 +1186,12 @@ hildon_font_selection_dialog_show_preview (HildonFontSelectionDialog *font attr = pango_attr_family_new (str); add_preview_text_attr (list, attr, 0, strlen (_("ecdg_fi_preview_font_preview_reference"))); } - g_free (str); + if (str != NULL) + g_free (str); + + str = NULL; - /*size*/ + /* size */ if (size_set) { attr = pango_attr_size_new (size * PANGO_SCALE); @@ -1205,6 +1206,12 @@ hildon_font_selection_dialog_show_preview (HildonFontSelectionDialog *font GTK_WINDOW (fontsel)); gtk_widget_show_all (preview_dialog); + gtk_dialog_set_default_response (GTK_DIALOG (preview_dialog), GTK_RESPONSE_OK); + + GtkBox *action_area = (GtkBox *) GTK_DIALOG (preview_dialog)->action_area; + GtkWidget *button = ((GtkBoxChild *) ((GSList *) action_area->children)->data)->widget; + gtk_widget_grab_focus (button); + gtk_dialog_run (GTK_DIALOG (preview_dialog)); gtk_widget_destroy (preview_dialog); }