[gtranslator/dl-info: 1/2] Add set_info function to tab




commit be66365733e32171cee8446e72409218bc135aa3
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Mon Dec 28 11:17:25 2020 +0100

    Add set_info function to tab
    
    This new method will show the infobar with the corresponding text as
    info.
    
    https://gitlab.gnome.org/GNOME/gtranslator/-/issues/124

 src/gtr-io-error-info-bar.c | 23 +++++++++++++++++++++++
 src/gtr-io-error-info-bar.h |  3 +++
 src/gtr-tab.c               | 17 +++++++++++++++++
 src/gtr-tab.h               |  2 ++
 4 files changed, 45 insertions(+)
---
diff --git a/src/gtr-io-error-info-bar.c b/src/gtr-io-error-info-bar.c
index 5b3f8c2bf..108b1127e 100644
--- a/src/gtr-io-error-info-bar.c
+++ b/src/gtr-io-error-info-bar.c
@@ -136,3 +136,26 @@ create_error_info_bar (const gchar * primary_text,
 
   return infobar;
 }
+
+GtkWidget *
+create_info_info_bar (const gchar * primary_text,
+                      const gchar * secondary_text)
+{
+  GtkWidget *infobar;
+
+  infobar = gtk_info_bar_new_with_buttons (_("_OK"),
+                                           GTK_RESPONSE_OK, NULL);
+
+  gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
+
+  set_info_bar_text_and_icon (GTK_INFO_BAR (infobar),
+                              "dialog-information-symbolic",
+                              primary_text, secondary_text);
+
+  g_signal_connect (G_OBJECT (infobar), "response",
+                    G_CALLBACK (gtk_widget_hide), NULL);
+
+  gtk_widget_show (infobar);
+
+  return infobar;
+}
diff --git a/src/gtr-io-error-info-bar.h b/src/gtr-io-error-info-bar.h
index f5a53c302..4446dbb41 100644
--- a/src/gtr-io-error-info-bar.h
+++ b/src/gtr-io-error-info-bar.h
@@ -26,5 +26,8 @@ G_BEGIN_DECLS
   GtkWidget * create_error_info_bar (const gchar * primary_text,
                                      const gchar * secondary_text);
 
+  GtkWidget * create_info_info_bar (const gchar * primary_text,
+                                    const gchar * secondary_text);
+
 G_END_DECLS
 #endif
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index e739103cb..6a0080527 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -1928,6 +1928,23 @@ gtr_tab_set_info_bar (GtrTab * tab, GtkWidget * infobar)
                              (gpointer *) & priv->infobar);
 }
 
+/**
+ * gtr_tab_set_info:
+ * @tab: a #GtrTab
+ * @info: a string to show
+ *
+ * Sets the @info to be shown in the @infobar.
+ */
+void
+gtr_tab_set_info (GtrTab * tab,
+                  const char * primary,
+                  const char * secondary)
+{
+  GtkWidget *infobar;
+  infobar = create_info_info_bar (primary, secondary);
+  gtr_tab_set_info_bar (tab, infobar);
+}
+
 GtrMsg *
 gtr_tab_get_msg (GtrTab *tab)
 {
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index aa17b148d..57c7e8e48 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -152,6 +152,8 @@ void gtr_tab_go_to_number (GtrTab * tab, gint number);
 
 void gtr_tab_set_info_bar (GtrTab * tab, GtkWidget * infobar);
 
+void gtr_tab_set_info (GtrTab * tab, const char * primary, const char * secondary);
+
 GtrMsg * gtr_tab_get_msg (GtrTab *tab);
 
 void gtr_tab_set_progress (GtrTab *tab, gint trans, gint untrans, gint fuzzy);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]