[gedit/file_too_big: 3/11] Extract code to method
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/file_too_big: 3/11] Extract code to method
- Date: Wed, 24 Mar 2021 15:01:10 +0000 (UTC)
commit c6c75b86c912088cae3d655f5eca4bbca89898ac
Author: Jordi Mas <jmas softcatala org>
Date: Mon Mar 22 21:22:54 2021 +0100
Extract code to method
gedit/gedit-io-error-info-bar.c | 74 +++++++++++++++--------------------------
1 file changed, 27 insertions(+), 47 deletions(-)
---
diff --git a/gedit/gedit-io-error-info-bar.c b/gedit/gedit-io-error-info-bar.c
index b4805944e..60db16ffa 100644
--- a/gedit/gedit-io-error-info-bar.c
+++ b/gedit/gedit-io-error-info-bar.c
@@ -395,31 +395,15 @@ create_combo_box (GtkWidget *info_bar,
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
}
-static GtkWidget *
-create_file_too_big_error_info_bar (const gchar *primary_text,
- const gchar *secondary_text,
- gboolean edit_anyway)
+static void
+create_primary_and_secondary_widgets_info_bar(GtkWidget *vbox, const gchar *primary_text,
+ const gchar *secondary_text)
{
- GtkWidget *info_bar;
- GtkWidget *hbox_content;
- GtkWidget *vbox;
gchar *primary_markup;
gchar *secondary_markup;
GtkWidget *primary_label;
GtkWidget *secondary_label;
- info_bar = gtk_info_bar_new ();
- gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
-
- gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
- _("_Continue loading"),
- GTK_RESPONSE_ACCEPT);
-
- hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
-
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
primary_label = gtk_label_new (primary_markup);
g_free (primary_markup);
@@ -443,7 +427,30 @@ create_file_too_big_error_info_bar (const gchar *primary_text,
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
}
+}
+
+static GtkWidget *
+create_file_too_big_error_info_bar (const gchar *primary_text,
+ const gchar *secondary_text,
+ gboolean edit_anyway)
+{
+ GtkWidget *info_bar;
+ GtkWidget *hbox_content;
+ GtkWidget *vbox;
+
+ info_bar = gtk_info_bar_new ();
+ gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
+
+ gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+ _("_Continue loading"),
+ GTK_RESPONSE_ACCEPT);
+ hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
+
+ create_primary_and_secondary_widgets_info_bar (vbox, primary_text, secondary_text);
gtk_widget_show_all (hbox_content);
set_contents (info_bar, hbox_content);
@@ -458,10 +465,6 @@ create_conversion_error_info_bar (const gchar *primary_text,
GtkWidget *info_bar;
GtkWidget *hbox_content;
GtkWidget *vbox;
- gchar *primary_markup;
- gchar *secondary_markup;
- GtkWidget *primary_label;
- GtkWidget *secondary_label;
info_bar = gtk_info_bar_new ();
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
@@ -491,30 +494,7 @@ create_conversion_error_info_bar (const gchar *primary_text,
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
- primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
- primary_label = gtk_label_new (primary_markup);
- g_free (primary_markup);
- gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
- gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
- gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
- gtk_widget_set_can_focus (primary_label, TRUE);
- gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
-
- if (secondary_text != NULL)
- {
- secondary_markup = g_strdup_printf ("<small>%s</small>",
- secondary_text);
- secondary_label = gtk_label_new (secondary_markup);
- g_free (secondary_markup);
- gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
- gtk_widget_set_can_focus (secondary_label, TRUE);
- gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
- gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
- }
-
+ create_primary_and_secondary_widgets_info_bar (vbox, primary_text, secondary_text);
create_combo_box (info_bar, vbox);
gtk_widget_show_all (hbox_content);
set_contents (info_bar, hbox_content);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]