use gtk_window_present() to raise the dialog; some code cleanup.

2003-02-04  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpfontselection-dialog.c: use gtk_window_present()
	to raise the dialog; some code cleanup.
This commit is contained in:
Sven Neumann
2003-02-04 00:43:49 +00:00
committed by Sven Neumann
parent 2c708acab4
commit 07df250a29
2 changed files with 44 additions and 34 deletions

View File

@ -1,3 +1,8 @@
2003-02-04 Sven Neumann <sven@gimp.org>
* app/widgets/gimpfontselection-dialog.c: use gtk_window_present()
to raise the dialog; some code cleanup.
2003-02-04 Sven Neumann <sven@gimp.org> 2003-02-04 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-selection.[ch] * app/display/gimpdisplayshell-selection.[ch]

View File

@ -111,6 +111,7 @@ gimp_font_selection_dialog_new (GimpFontSelection *fontsel)
{ {
GimpFontSelectionDialog *dialog; GimpFontSelectionDialog *dialog;
GtkListStore *model; GtkListStore *model;
GtkTreeSelection *select;
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
GtkWidget *scrolled_win; GtkWidget *scrolled_win;
GtkWidget *table; GtkWidget *table;
@ -181,8 +182,8 @@ gimp_font_selection_dialog_new (GimpFontSelection *fontsel)
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->family_list), gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->family_list),
FALSE); FALSE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list)), select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list));
GTK_SELECTION_BROWSE); gtk_tree_selection_set_mode (select, GTK_SELECTION_BROWSE);
scrolled_win = gtk_scrolled_window_new (NULL, NULL); scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
@ -216,8 +217,8 @@ gimp_font_selection_dialog_new (GimpFontSelection *fontsel)
gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->face_list), column); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->face_list), column);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->face_list), FALSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->face_list), FALSE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list)), select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list));
GTK_SELECTION_BROWSE); gtk_tree_selection_set_mode (select, GTK_SELECTION_BROWSE);
scrolled_win = gtk_scrolled_window_new (NULL, NULL); scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
@ -254,13 +255,15 @@ gimp_font_selection_dialog_new (GimpFontSelection *fontsel)
/* Insert the fonts. */ /* Insert the fonts. */
gimp_font_selection_dialog_show_available_fonts (dialog); gimp_font_selection_dialog_show_available_fonts (dialog);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list)), "changed", select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list));
g_signal_connect (select, "changed",
G_CALLBACK (gimp_font_selection_dialog_select_family), G_CALLBACK (gimp_font_selection_dialog_select_family),
dialog); dialog);
gimp_font_selection_dialog_show_available_styles (dialog); gimp_font_selection_dialog_show_available_styles (dialog);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list)), "changed", select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list));
g_signal_connect (select, "changed",
G_CALLBACK (gimp_font_selection_dialog_select_style), G_CALLBACK (gimp_font_selection_dialog_select_style),
dialog); dialog);
@ -291,7 +294,7 @@ gimp_font_selection_dialog_show (GimpFontSelectionDialog *dialog)
{ {
g_return_if_fail (dialog != NULL); g_return_if_fail (dialog != NULL);
gtk_widget_show (dialog->dialog); gtk_window_present (GTK_WINDOW (dialog->dialog));
} }
static void static void
@ -325,6 +328,7 @@ gimp_font_selection_dialog_set_font_desc (GimpFontSelectionDialog *dialog,
{ {
PangoFontFamily *new_family = NULL; PangoFontFamily *new_family = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeSelection *select;
GtkTreeIter iter; GtkTreeIter iter;
gboolean valid; gboolean valid;
const gchar *name; const gchar *name;
@ -333,10 +337,12 @@ gimp_font_selection_dialog_set_font_desc (GimpFontSelectionDialog *dialog,
g_return_if_fail (desc != NULL); g_return_if_fail (desc != NULL);
name = pango_font_description_get_family (desc); name = pango_font_description_get_family (desc);
if (!name)
return;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->family_list)); model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->family_list));
for (valid = gtk_tree_model_get_iter_root (model, &iter); for (valid = gtk_tree_model_get_iter_root (model, &iter);
valid; valid && !new_family;
valid = gtk_tree_model_iter_next (model, &iter)) valid = gtk_tree_model_iter_next (model, &iter))
{ {
PangoFontFamily *family; PangoFontFamily *family;
@ -347,21 +353,13 @@ gimp_font_selection_dialog_set_font_desc (GimpFontSelectionDialog *dialog,
new_family = family; new_family = family;
g_object_unref (family); g_object_unref (family);
if (new_family)
{
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list)), &iter);
break;
}
} }
if (!new_family) if (!new_family && !gtk_tree_model_get_iter_root (model, &iter))
{
if (!gtk_tree_model_get_iter_root (model, &iter))
return; return;
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list)), &iter); select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->family_list));
} gtk_tree_selection_select_iter (select, &iter);
gimp_font_selection_dialog_show_available_styles (dialog); gimp_font_selection_dialog_show_available_styles (dialog);
@ -378,7 +376,9 @@ gimp_font_selection_dialog_set_font_desc (GimpFontSelectionDialog *dialog,
if (font_description_style_equal (tmp_desc, desc)) if (font_description_style_equal (tmp_desc, desc))
{ {
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list)), &iter); select =
gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list));
gtk_tree_selection_select_iter (select, &iter);
pango_font_description_free (tmp_desc); pango_font_description_free (tmp_desc);
g_object_unref (face); g_object_unref (face);
@ -573,6 +573,7 @@ gimp_font_selection_dialog_show_available_styles (GimpFontSelectionDialog *dialo
PangoFontFace **faces; PangoFontFace **faces;
PangoFontDescription *old_desc; PangoFontDescription *old_desc;
GtkListStore *model; GtkListStore *model;
GtkTreeSelection *select;
GtkTreeIter match_row; GtkTreeIter match_row;
PangoFontFace *match_face = NULL; PangoFontFace *match_face = NULL;
gint n_faces, i; gint n_faces, i;
@ -589,6 +590,9 @@ gimp_font_selection_dialog_show_available_styles (GimpFontSelectionDialog *dialo
gtk_list_store_clear (model); gtk_list_store_clear (model);
if (n_faces < 0)
return;
for (i = 0; i < n_faces; i++) for (i = 0; i < n_faces; i++)
{ {
GtkTreeIter iter; GtkTreeIter iter;
@ -625,7 +629,8 @@ gimp_font_selection_dialog_show_available_styles (GimpFontSelectionDialog *dialo
g_free (faces); g_free (faces);
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list)), &match_row); select = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->face_list));
gtk_tree_selection_select_iter (select, &match_row);
} }
static void static void