diff options
Diffstat (limited to 'embed')
-rw-r--r-- | embed/downloader-view.c | 18 | ||||
-rwxr-xr-x | embed/find-dialog.c | 96 | ||||
-rwxr-xr-x | embed/print-dialog.c | 91 |
3 files changed, 109 insertions, 96 deletions
diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 4682b9c76..2ae57ce31 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -84,12 +84,12 @@ enum static const EphyDialogProperty properties [] = { - { PROP_WINDOW, "download_manager_dialog", NULL, PT_NORMAL, NULL}, - { PROP_TREEVIEW, "clist", NULL, PT_NORMAL, NULL }, - { PROP_PAUSE_BUTTON, "pause_button", NULL, PT_NORMAL, NULL }, - { PROP_ABORT_BUTTON, "abort_button", NULL, PT_NORMAL, NULL }, + { "download_manager_dialog", NULL, PT_NORMAL, 0 }, + { "clist", NULL, PT_NORMAL, 0 }, + { "pause_button", NULL, PT_NORMAL, 0 }, + { "abort_button", NULL, PT_NORMAL, 0 }, - { -1, NULL, NULL } + { NULL } }; static void @@ -409,10 +409,10 @@ downloader_view_build_ui (DownloaderView *dv) "download_manager_dialog"); /* lookup needed widgets */ - priv->window = ephy_dialog_get_control(d, PROP_WINDOW); - priv->treeview = ephy_dialog_get_control (d, PROP_TREEVIEW); - priv->pause_button = ephy_dialog_get_control (d, PROP_PAUSE_BUTTON); - priv->abort_button = ephy_dialog_get_control (d, PROP_ABORT_BUTTON); + priv->window = ephy_dialog_get_control(d, properties[PROP_WINDOW].id); + priv->treeview = ephy_dialog_get_control (d, properties[PROP_TREEVIEW].id); + priv->pause_button = ephy_dialog_get_control (d, properties[PROP_PAUSE_BUTTON].id); + priv->abort_button = ephy_dialog_get_control (d, properties[PROP_ABORT_BUTTON].id); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), GTK_SELECTION_SINGLE); diff --git a/embed/find-dialog.c b/embed/find-dialog.c index ace630cda..932511cec 100755 --- a/embed/find-dialog.c +++ b/embed/find-dialog.c @@ -47,6 +47,7 @@ static GObjectClass *parent_class = NULL; struct FindDialogPrivate { EphyEmbed *old_embed; + gboolean initialised; }; enum @@ -62,13 +63,13 @@ enum static const EphyDialogProperty properties [] = { - { WINDOW_PROP, "find_dialog", NULL, PT_NORMAL, NULL }, - { MATCH_CASE_PROP, "case_check", CONF_FIND_MATCH_CASE, PT_NORMAL, NULL }, - { AUTOWRAP_PROP, "wrap_check", CONF_FIND_AUTOWRAP, PT_NORMAL, NULL }, - { WORD_PROP, "find_entry", CONF_FIND_WORD, PT_NORMAL, NULL }, - { BACK_BUTTON, "back_button", NULL, PT_NORMAL, NULL }, - { FORWARD_BUTTON, "forward_button", NULL, PT_NORMAL, NULL }, - { -1, NULL, NULL } + { "find_dialog", NULL, PT_NORMAL, 0 }, + { "case_check", CONF_FIND_MATCH_CASE, PT_NORMAL, 0 }, + { "wrap_check", CONF_FIND_AUTOWRAP, PT_NORMAL, 0 }, + { "find_entry", CONF_FIND_WORD, PT_NORMAL, 0 }, + { "back_button", NULL, PT_NORMAL, 0 }, + { "forward_button", NULL, PT_NORMAL, 0 }, + { NULL } }; GType @@ -105,41 +106,15 @@ update_navigation_controls (FindDialog *dialog, gboolean prev, gboolean next) { GtkWidget *button; - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), BACK_BUTTON); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[BACK_BUTTON].id); gtk_widget_set_sensitive (button, prev); - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), FORWARD_BUTTON); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[FORWARD_BUTTON].id); gtk_widget_set_sensitive (button, next); } -static void -impl_show (EphyDialog *dialog) -{ - - EPHY_DIALOG_CLASS (parent_class)->show (dialog); - - /* Focus the text entry. This will correctly select or leave - * unselected the existing text in the entry depending on the - * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc. - */ - gtk_widget_grab_focus (ephy_dialog_get_control (dialog, WORD_PROP)); -} - -static void -find_dialog_class_init (FindDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EphyDialogClass *ephy_dialog_class; - - parent_class = g_type_class_peek_parent (klass); - ephy_dialog_class = EPHY_DIALOG_CLASS (klass); - - object_class->finalize = find_dialog_finalize; - - ephy_dialog_class->show = impl_show; - - g_type_class_add_private (object_class, sizeof (FindDialogPrivate)); -} static void set_properties (FindDialog *find_dialog) @@ -153,8 +128,10 @@ set_properties (FindDialog *find_dialog) EphyDialog *dialog = EPHY_DIALOG (find_dialog); EphyEmbed *embed; + if (!find_dialog->priv->initialised) return; + /* get the search string from the entry field */ - ephy_dialog_get_value (dialog, WORD_PROP, &word); + ephy_dialog_get_value (dialog, properties[WORD_PROP].id, &word); search_string = g_strdup (g_value_get_string (&word)); g_value_unset (&word); @@ -167,11 +144,11 @@ set_properties (FindDialog *find_dialog) return; } - ephy_dialog_get_value (dialog, MATCH_CASE_PROP, &match_case); + ephy_dialog_get_value (dialog, properties[MATCH_CASE_PROP].id, &match_case); b_match_case = g_value_get_boolean (&match_case); g_value_unset (&match_case); - ephy_dialog_get_value (dialog, AUTOWRAP_PROP, &wrap); + ephy_dialog_get_value (dialog, properties[AUTOWRAP_PROP].id, &wrap); b_wrap = g_value_get_boolean (&wrap); g_value_unset (&wrap); @@ -185,6 +162,39 @@ set_properties (FindDialog *find_dialog) } static void +impl_show (EphyDialog *dialog) +{ + EPHY_DIALOG_CLASS (parent_class)->show (dialog); + + EPHY_FIND_DIALOG (dialog)->priv->initialised = TRUE; + + set_properties (EPHY_FIND_DIALOG (dialog)); + + /* Focus the text entry. This will correctly select or leave + * unselected the existing text in the entry depending on the + * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc. + */ + gtk_widget_grab_focus (ephy_dialog_get_control + (dialog, properties[WORD_PROP].id)); +} + +static void +find_dialog_class_init (FindDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + EphyDialogClass *ephy_dialog_class; + + parent_class = g_type_class_peek_parent (klass); + ephy_dialog_class = EPHY_DIALOG_CLASS (klass); + + object_class->finalize = find_dialog_finalize; + + ephy_dialog_class->show = impl_show; + + g_type_class_add_private (object_class, sizeof (FindDialogPrivate)); +} + +static void sync_page_change (EphyEmbed *embed, const char *address, FindDialog *dialog) { g_return_if_fail (EPHY_IS_EMBED (embed)); @@ -238,6 +248,7 @@ find_dialog_init (FindDialog *dialog) dialog->priv = EPHY_FIND_DIALOG_GET_PRIVATE (dialog); dialog->priv->old_embed = NULL; + dialog->priv->initialised = FALSE; ephy_dialog_construct (EPHY_DIALOG(dialog), properties, @@ -245,7 +256,8 @@ find_dialog_init (FindDialog *dialog) "find_dialog"); update_navigation_controls (dialog, TRUE, TRUE); - window = ephy_dialog_get_control (EPHY_DIALOG (dialog), WINDOW_PROP); + window = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[WINDOW_PROP].id); icon = gtk_widget_render_icon (window, GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, @@ -293,7 +305,7 @@ find_dialog_new_with_parent (GtkWidget *window, dialog = EPHY_FIND_DIALOG (g_object_new (EPHY_TYPE_FIND_DIALOG, "embed", embed, - "ParentWindow", window, + "parent-window", window, NULL)); return EPHY_DIALOG(dialog); diff --git a/embed/print-dialog.c b/embed/print-dialog.c index 0cbe44d59..e09b1a6c9 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -100,28 +100,28 @@ enum static const EphyDialogProperty properties [] = { - { WINDOW_PROP, "print_dialog", NULL, PT_NORMAL, NULL }, - { PRINTON_PROP, "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, NULL }, - { PRINTER_PROP, "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, NULL }, - { FILE_PROP, "file_entry", CONF_PRINT_FILE, PT_NORMAL, NULL }, - { PAPER_PROP,"A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, NULL }, - { TOP_PROP, "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, NULL }, - { BOTTOM_PROP, "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, NULL }, - { LEFT_PROP,"left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, NULL }, - { RIGHT_PROP, "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, NULL }, - { PAGE_TITLE_PROP, "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, NULL }, - { PAGE_URL_PROP, "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, NULL }, - { PAGE_NUMBERS_PROP, "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, NULL }, - { DATE_PROP, "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, NULL }, - { ALL_PAGES_PROP, "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, NULL }, - { TO_PROP, "to_spinbutton", NULL, PT_NORMAL, NULL }, - { FROM_PROP, "from_spinbutton", NULL, PT_NORMAL, NULL }, - { COLOR_PROP, "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, NULL }, - { ORIENTATION_PROP, "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, NULL }, - { PREVIEW_PROP, "preview_button", NULL, PT_NORMAL, NULL }, - { SELECTION_PROP, "selection_radiobutton", NULL, PT_NORMAL, NULL}, - - { -1, NULL, NULL } + { "print_dialog", NULL, PT_NORMAL, 0 }, + { "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, 0 }, + { "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, 0 }, + { "file_entry", CONF_PRINT_FILE, PT_NORMAL, 0 }, + { "A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, G_TYPE_STRING }, + { "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, 0 }, + { "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, 0 }, + { "left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, 0 }, + { "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, 0 }, + { "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, 0 }, + { "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, 0 }, + { "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, 0 }, + { "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, 0 }, + { "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, 0 }, + { "to_spinbutton", NULL, PT_NORMAL, 0 }, + { "from_spinbutton", NULL, PT_NORMAL, 0 }, + { "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, 0 }, + { "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, 0 }, + { "preview_button", NULL, PT_NORMAL, 0 }, + { "selection_radiobutton", NULL, PT_NORMAL, 0 }, + + { NULL } }; static const @@ -176,7 +176,7 @@ impl_show (EphyDialog *dialog) /* disappear preview button */ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), - PREVIEW_PROP); + properties[PREVIEW_PROP].id); gtk_widget_hide (button); } @@ -187,7 +187,7 @@ impl_show (EphyDialog *dialog) /* Make selection button disabled */ widget = ephy_dialog_get_control (EPHY_DIALOG (dialog), - SELECTION_PROP); + properties[SELECTION_PROP].id); gtk_widget_set_sensitive (widget, FALSE); @@ -195,7 +195,7 @@ impl_show (EphyDialog *dialog) { GtkWidget *all_pages; all_pages = ephy_dialog_get_control (EPHY_DIALOG (dialog), - ALL_PAGES_PROP); + properties[ALL_PAGES_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (all_pages), TRUE); } } @@ -237,9 +237,10 @@ print_dialog_init (PrintDialog *dialog) properties, "print.glade", "print_dialog"); - dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog), WINDOW_PROP); + dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog), + properties[WINDOW_PROP].id); - ephy_dialog_add_enum (EPHY_DIALOG (dialog), PAPER_PROP, + ephy_dialog_add_enum (EPHY_DIALOG (dialog), properties[PAPER_PROP].id, n_paper_format_enum, paper_format_enum); icon = gtk_widget_render_icon (dialog->priv->window, @@ -278,7 +279,7 @@ print_dialog_new_with_parent (GtkWidget *window, dialog = EPHY_PRINT_DIALOG (g_object_new (EPHY_TYPE_PRINT_DIALOG, "embed", embed, - "ParentWindow", window, + "parent-window", window, NULL)); if (ret_info != NULL) @@ -330,15 +331,15 @@ print_get_info (EphyDialog *dialog) info = g_new0 (EmbedPrintInfo, 1); - ephy_dialog_get_value (dialog, PRINTON_PROP, &print_to_file); + ephy_dialog_get_value (dialog, properties[PRINTON_PROP].id, &print_to_file); info->print_to_file = g_value_get_int (&print_to_file); g_value_unset (&print_to_file); - ephy_dialog_get_value (dialog, PRINTER_PROP, &printer); + ephy_dialog_get_value (dialog, properties[PRINTER_PROP].id, &printer); info->printer = g_strdup (g_value_get_string (&printer)); g_value_unset (&printer); - ephy_dialog_get_value (dialog, FILE_PROP, &file); + ephy_dialog_get_value (dialog, properties[FILE_PROP].id, &file); filename = g_value_get_string (&file); if (filename != NULL) { @@ -350,64 +351,64 @@ print_get_info (EphyDialog *dialog) } g_value_unset (&file); - ephy_dialog_get_value (dialog, BOTTOM_PROP, &bottom_margin); + ephy_dialog_get_value (dialog, properties[BOTTOM_PROP].id, &bottom_margin); info->bottom_margin = g_value_get_float (&bottom_margin); g_value_unset (&bottom_margin); - ephy_dialog_get_value (dialog, LEFT_PROP, &left_margin); + ephy_dialog_get_value (dialog, properties[LEFT_PROP].id, &left_margin); info->left_margin = g_value_get_float (&left_margin); g_value_unset (&left_margin); - ephy_dialog_get_value (dialog, TOP_PROP, &top_margin); + ephy_dialog_get_value (dialog, properties[TOP_PROP].id, &top_margin); info->top_margin = g_value_get_float (&top_margin); g_value_unset (&top_margin); - ephy_dialog_get_value (dialog, RIGHT_PROP, &right_margin); + ephy_dialog_get_value (dialog, properties[RIGHT_PROP].id, &right_margin); info->right_margin = g_value_get_float (&right_margin); g_value_unset (&right_margin); - ephy_dialog_get_value (dialog, FROM_PROP, &from_page); + ephy_dialog_get_value (dialog, properties[FROM_PROP].id, &from_page); info->from_page = g_value_get_float (&from_page); g_value_unset (&from_page); - ephy_dialog_get_value (dialog, TO_PROP, &to_page); + ephy_dialog_get_value (dialog, properties[TO_PROP].id, &to_page); info->to_page = g_value_get_float (&to_page); g_value_unset (&to_page); - ephy_dialog_get_value (dialog, PAPER_PROP, &paper); + ephy_dialog_get_value (dialog, properties[PAPER_PROP].id, &paper); info->paper = g_strdup (paper_format_enum[g_value_get_int (&paper)]); g_value_unset (&paper); - ephy_dialog_get_value (dialog, ALL_PAGES_PROP, &pages); + ephy_dialog_get_value (dialog, properties[ALL_PAGES_PROP].id, &pages); info->pages = g_value_get_int (&pages); g_value_unset (&pages); - ephy_dialog_get_value (dialog, COLOR_PROP, &print_color); + ephy_dialog_get_value (dialog, properties[COLOR_PROP].id, &print_color); info->print_color = !g_value_get_int (&print_color); g_value_unset (&print_color); - ephy_dialog_get_value (dialog, ORIENTATION_PROP, &orientation); + ephy_dialog_get_value (dialog, properties[ORIENTATION_PROP].id, &orientation); info->orientation = g_value_get_int (&orientation); g_value_unset (&orientation); info->frame_type = 0; - ephy_dialog_get_value (dialog, PAGE_TITLE_PROP, &page_title); + ephy_dialog_get_value (dialog, properties[PAGE_TITLE_PROP].id, &page_title); info->header_left_string = g_value_get_boolean (&page_title) ? g_strdup ("&T") : g_strdup (""); g_value_unset (&page_title); - ephy_dialog_get_value (dialog, PAGE_URL_PROP, &page_url); + ephy_dialog_get_value (dialog, properties[PAGE_URL_PROP].id, &page_url); info->header_right_string = g_value_get_boolean (&page_url) ? g_strdup ("&U") : g_strdup (""); g_value_unset (&page_url); - ephy_dialog_get_value (dialog, PAGE_NUMBERS_PROP, &page_numbers); + ephy_dialog_get_value (dialog, properties[PAGE_NUMBERS_PROP].id, &page_numbers); info->footer_left_string = g_value_get_boolean (&page_numbers) ? g_strdup ("&PT") : g_strdup (""); g_value_unset (&page_numbers); - ephy_dialog_get_value (dialog, DATE_PROP, &date); + ephy_dialog_get_value (dialog, properties[DATE_PROP].id, &date); info->footer_right_string = g_value_get_boolean (&date) ? g_strdup ("&D") : g_strdup (""); g_value_unset (&date); |