[gtranslator/gtk4: 23/79] removed notebook from project and fixed codeview, message_count *progress_bar, window_title, removed ta




commit 140eb472e013954aead4ed783fa0208d58b013d7
Author: afshan ahmed khan <afshanahmeda2k gmail com>
Date:   Sat May 21 07:03:22 2022 +0530

    removed notebook from project and fixed codeview,message_count *progress_bar,window_title,removed tab 
from window private

 src/codeview/gtr-codeview.c   |   4 +-
 src/gtr-notebook.ui           | 514 ------------------------------------------
 src/gtr-tab.c                 |   3 +-
 src/gtr-window.c              |  59 +++--
 src/gtranslator.gresource.xml |   1 -
 src/meson.build               |   6 +-
 6 files changed, 48 insertions(+), 539 deletions(-)
---
diff --git a/src/codeview/gtr-codeview.c b/src/codeview/gtr-codeview.c
index e1c221aa..a0ea1126 100644
--- a/src/codeview/gtr-codeview.c
+++ b/src/codeview/gtr-codeview.c
@@ -577,7 +577,6 @@ gtr_code_view_new (GtrWindow *window)
   GtrCodeViewPrivate *priv = gtr_code_view_get_instance_private (self);
   GtkWidget *tab;
   GdkDisplay *display;
-  GList *tabs, *l;
 
   tab = GTK_WIDGET (gtr_window_get_active_tab (priv->window));
   display = gtk_widget_get_display (tab);
@@ -610,8 +609,7 @@ gtr_code_view_new (GtrWindow *window)
     GList *msg;
     po = gtr_tab_get_po (GTR_TAB (tab));
     msg = gtr_po_get_current_message (po);
-    page_added_cb (GTR_TAB(tab), self);
+    page_added_cb (tab, self);
     showed_message_cb (GTR_TAB (tab), msg->data, self);
-
   return self;
 }
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index ed0eb2f3..93de8bc6 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -1147,7 +1147,7 @@ gtr_tab_enable_save (GtrTab *tab,
 
 void
 gtr_tab_update_undo_buttons (GtrTab *tab,
-                                  GtrView     *view)
+                                  GtrView  *view)
 {
   GtkSourceBuffer *active_document;
   GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
@@ -1156,6 +1156,7 @@ gtr_tab_update_undo_buttons (GtrTab *tab,
 
   active_document =
     GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+  g_return_if_fail(active_document);
 
   can_undo = gtk_source_buffer_can_undo (active_document);
   can_redo = gtk_source_buffer_can_redo (active_document);
diff --git a/src/gtr-window.c b/src/gtr-window.c
index dc5f376a..d0876b30 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -77,7 +77,6 @@ typedef struct
   GtkWidget *stack;
 
   GtkWidget *projects;
-  GtkWidget *tab;
   GtkWidget *dlteams;
 
   GtrTab *active_tab;
@@ -116,9 +115,8 @@ update_undo_state (GtrTab     *tab,
                    GtrMsg     *msg,
                    GtrWindow  *window)
 {
-  GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
   GtrView *active_view = gtr_window_get_active_view (window);
-  gtr_tab_update_undo_buttons (GTR_TAB (priv->tab), active_view);
+  gtr_tab_update_undo_buttons (GTR_TAB (tab), active_view);
 }
 
 /*
@@ -129,14 +127,14 @@ update_undo_state (GtrTab     *tab,
  */
 static void
 gtr_window_update_statusbar_message_count (GtrTab * tab,
-                                           GtrMsg * message,
+                                           GtrMsg *message,
                                            GtrWindow * window)
 {
   GtrTab *active_tab;
   GtrPo *po;
   gint translated, fuzzy, untranslated;
 
-  g_return_if_fail (GTR_IS_MSG (message));
+  //g_return_if_fail (GTR_IS_MSG (message));
 
   po = gtr_tab_get_po (tab);
 
@@ -204,7 +202,6 @@ set_window_title (GtrWindow * window, gboolean with_path)
       active_tab = gtr_window_get_active_tab (window);
       po = gtr_tab_get_po (active_tab);
       state = gtr_po_get_state (gtr_tab_get_po (active_tab));
-      po = gtr_tab_get_po (active_tab);
       file = gtr_po_get_location (po);
       basename = g_file_get_basename (file);
 
@@ -212,13 +209,13 @@ set_window_title (GtrWindow * window, gboolean with_path)
         {
           /* Translators: this is the title of the window with a modified document */
           title = g_strdup_printf (_("*%s — Translation Editor"), basename);
-          gtr_tab_enable_save (GTR_TAB (priv->tab), TRUE);
+          gtr_tab_enable_save (GTR_TAB (priv->active_tab), TRUE);
         }
       else
         {
           /* Translators: this is the title of the window with a document opened */
           title = g_strdup_printf (_("%s — Translation Editor"), basename);
-          gtr_tab_enable_save (GTR_TAB (priv->tab), FALSE);
+          gtr_tab_enable_save (GTR_TAB (priv->active_tab), FALSE);
         }
 
       g_free (basename);
@@ -346,6 +343,7 @@ gtr_window_init (GtrWindow *window)
 
   priv->search_bar_shown = FALSE;
   priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+  priv->active_tab = NULL;
 
   gtk_widget_init_template (GTK_WIDGET (window));
 
@@ -428,9 +426,6 @@ gtr_window_init (GtrWindow *window)
                                                             "max-length-diff"));
   gtr_translation_memory_set_max_items (priv->translation_memory, 10);
 
-  // code view
-  //priv->codeview = gtr_code_view_new (window);
-
   gtr_window_show_projects (window);
 }
 
@@ -513,7 +508,7 @@ static void
 searchbar_toggled (GtrTab * tab, gboolean revealed, GtrWindow *window)
 {
   GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
-  gtr_tab_enable_find_button (GTR_TAB (priv->tab), revealed);
+  gtr_tab_enable_find_button (GTR_TAB (priv->active_tab), revealed);
 }
 
 /***************************** Public funcs ***********************************/
@@ -545,8 +540,33 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
   g_list_free (tabs);
 
   tab = gtr_tab_new (po, GTK_WINDOW (window));
+  g_return_if_fail (GTR_IS_TAB (tab));
   priv->active_tab = tab;
+
+  set_window_title (window, TRUE);
+  g_signal_connect_after (tab,
+                          "message_changed",
+                          G_CALLBACK
+                          (gtr_window_update_statusbar_message_count),
+                          window);
+
+  g_signal_connect_after (tab,
+                          "message_changed",
+                          G_CALLBACK (update_undo_state),
+                          window);
+  g_signal_connect_after (tab,
+                          "showed-message",
+                          G_CALLBACK (update_undo_state),
+                          window);
+
   gtk_widget_show (GTK_WIDGET (tab));
+  gtr_window_update_statusbar_message_count(priv->active_tab,NULL, window);
+
+  //update_undo_state (NULL, NULL, window);
+
+  //GtkWidget *label;
+  //label = create_tab_label (notebook, tab);
+  //gtk_notebook_append_page (GTK_NOTEBOOK (notebook), GTK_WIDGET (tab), label);
 
   /*
   gtr_notebook_add_page (GTR_NOTEBOOK (priv->notebook), tab);
@@ -558,6 +578,9 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
                        gtr_tab_get_header (GTR_TAB (priv->active_tab)),
                        "poeditor");
 
+  // code view
+  priv->codeview = gtr_code_view_new (window);
+
   g_signal_connect_after (po,
                           "notify::state",
                           G_CALLBACK
@@ -614,10 +637,12 @@ gtr_window_get_all_tabs (GtrWindow * window)
                                                         (priv->notebook), i));
       i++;
     }*/
-  toret = g_list_append (toret,
-                        GTK_WIDGET(
-                          gtr_window_get_active_tab(window)));
-
+  GtrTab *tab = gtr_window_get_active_tab(window);
+  if (tab != NULL) {
+    toret = g_list_append (toret,
+                          GTK_WIDGET(
+                            gtr_window_get_active_tab(window)));
+  }
   return toret;
 }
 
@@ -704,7 +729,7 @@ gtr_window_get_all_views (GtrWindow * window,
                           gboolean original, gboolean translated)
 {
   GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
-  gint numtabs;
+  //gint numtabs;
   //gint i;
   GList *views = NULL;
   //GtkWidget *tab;
diff --git a/src/gtranslator.gresource.xml b/src/gtranslator.gresource.xml
index bb27c261..6c32d50e 100644
--- a/src/gtranslator.gresource.xml
+++ b/src/gtranslator.gresource.xml
@@ -8,7 +8,6 @@
     <file preprocess="xml-stripblanks">gtr-jump-dialog.ui</file>
     <file preprocess="xml-stripblanks">gtr-languages-fetcher.ui</file>
     <file preprocess="xml-stripblanks">gtr-message-table.ui</file>
-    <file preprocess="xml-stripblanks">gtr-notebook.ui</file>
     <file preprocess="xml-stripblanks">gtr-preferences-dialog.ui</file>
     <file preprocess="xml-stripblanks">gtr-profile-dialog.ui</file>
     <file preprocess="xml-stripblanks">gtr-tab.ui</file>
diff --git a/src/meson.build b/src/meson.build
index 99709746..5fbade24 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,7 +17,7 @@ enum_headers = files(
   'gtr-message-container.h',
   'gtr-message-table.h',
   'gtr-msg.h',
-  'gtr-notebook.h',
+  # 'gtr-notebook.h',
   'gtr-po.h',
   'gtr-profile.h',
   'gtr-tab-activatable.h',
@@ -54,7 +54,7 @@ sources = files(
   'gtr-message-table.c',
   'gtr-message-table-model.c',
   'gtr-msg.c',
-  'gtr-notebook.c',
+  # 'gtr-notebook.c',
   'gtr-po.c',
   'gtr-preferences-dialog.c',
   'gtr-profile.c',
@@ -105,7 +105,7 @@ resource_data = files(
   'gtr-jump-dialog.ui',
   'gtr-languages-fetcher.ui',
   'gtr-message-table.ui',
-  'gtr-notebook.ui',
+  # 'gtr-notebook.ui',
   'gtr-preferences-dialog.ui',
   'gtr-profile-dialog.ui',
   'gtr-tab.ui',


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