[gtranslator/gtk4: 24/79] removed notebook from project directory , fixed files related issues - file opening - saving without
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/gtk4: 24/79] removed notebook from project directory , fixed files related issues - file opening - saving without
- Date: Mon, 10 Oct 2022 16:31:19 +0000 (UTC)
commit fe405bb4b4a6244e9282cc12eda22e9e4eb6e4af
Author: afshan ahmed khan <afshanahmeda2k gmail com>
Date: Sun May 22 10:28:21 2022 +0530
removed notebook from project directory , fixed files related issues - file opening - saving without
close, multiple window issue , Headerbar issue
src/gtr-actions-file.c | 63 +++++++---
src/gtr-notebook.c | 324 -------------------------------------------------
src/gtr-notebook.h | 91 --------------
src/gtr-window.c | 62 ++++++----
src/gtr-window.h | 4 +-
5 files changed, 86 insertions(+), 458 deletions(-)
---
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index 405d4925..a6f31abc 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -36,7 +36,7 @@
#include "gtr-application.h"
#include "gtr-dirs.h"
#include "gtr-file-dialogs.h"
-#include "gtr-notebook.h"
+//#include "gtr-notebook.h"
#include "gtr-po.h"
#include "gtr-tab.h"
#include "gtr-utils.h"
@@ -246,13 +246,13 @@ void
gtr_open_file_dialog (GtrWindow * window)
{
GtkNativeDialog *dialog;
- //g_autoptr (GList) list = NULL;
- //list = get_modified_documents (window);
- /*if (list != NULL)
+ g_autoptr (GList) list = NULL;
+ list = get_modified_documents (window);
+ if (list != NULL)
{
if (!gtr_want_to_save_current_dialog (window))
return;
- }*/
+ }
dialog = gtr_file_chooser_new (GTK_WINDOW (window),
FILESEL_OPEN,
@@ -610,7 +610,8 @@ load_file_list (GtrWindow * window, const GSList * locations)
g_return_if_fail ((locations != NULL) && (locations->data != NULL));
// removing other tabs, for now on, we'll using single tab and multiples windows
- gtr_window_remove_all_pages (window);
+ // gtr_window_remove_all_pages (window);
+ gtr_window_remove_tab (window);
/* Remove the uris corresponding to documents already open
* in "window" and remove duplicates from "uris" list */
@@ -700,31 +701,33 @@ save_and_close_document (GtrPo * po, GtrWindow * window)
gtr_save_current_file_dialog (NULL, window);
- tab = gtr_tab_get_from_document (po);
+ //tab = gtr_tab_get_from_document (po);
- _gtr_window_close_tab (window, tab);
+ //_gtr_window_close_tab (window, tab);
+ gtr_window_remove_tab (window);
}
static void
close_all_tabs (GtrWindow * window)
{
+ gtr_window_remove_tab(window);
/*GtrNotebook *nb;
nb = gtr_window_get_notebook (window);
gtr_notebook_remove_all_pages (nb);
- //FIXME: This has to change once we add the close all documents menuitem
- gtk_widget_destroy (GTK_WIDGET (window));*/
+ //FIXME: This has to change once we add the close all documents menuitem*/
+ gtk_widget_destroy (GTK_WIDGET (window));
}
static void
save_and_close_all_documents (GList * unsaved_documents, GtrWindow * window)
{
GtrTab *tab;
- GList *l;
+ //GList *l;
GError *error = NULL;
- for (l = unsaved_documents; l != NULL; l = g_list_next (l))
+ /*for (l = unsaved_documents; l != NULL; l = g_list_next (l))
{
gtr_po_save_file (l->data, &error);
@@ -747,8 +750,25 @@ save_and_close_all_documents (GList * unsaved_documents, GtrWindow * window)
tab = gtr_tab_get_from_document (l->data);
_gtr_window_close_tab (window, tab);
- }
+ }*/
+ gtr_po_save_file(unsaved_documents->data,&error);
+ if(error)
+ {
+ GtkWidget *dialog;
+ GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ flags,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_present (GTK_WINDOW (dialog));
+ g_clear_error (&error);
+ return;
+ }
+
+ gtr_window_remove_tab (window);
gtk_widget_destroy (GTK_WIDGET (window));
}
@@ -810,7 +830,8 @@ close_confirmation_dialog_response_handler (GtrCloseConfirmationDialog
}
else
{
- const GList *unsaved_documents;
+ // right now is_closing_all is always true so this won't run therefore no need to consider this in
port from gtk3 to gtk4
+ /*const GList *unsaved_documents;
unsaved_documents =
gtr_close_confirmation_dialog_get_unsaved_documents (dlg);
@@ -818,7 +839,7 @@ close_confirmation_dialog_response_handler (GtrCloseConfirmationDialog
_gtr_window_close_tab (window,
gtr_tab_get_from_document
- (unsaved_documents->data));
+ (unsaved_documents->data));*/
}
break;
@@ -852,7 +873,8 @@ gtr_close_tab (GtrTab * tab, GtrWindow * window)
gtk_widget_show (dlg);
}
else
- _gtr_window_close_tab (window, tab);
+ //_gtr_window_close_tab (window, tab);
+ gtr_window_remove_tab(window);
}
void
@@ -889,10 +911,11 @@ get_modified_documents (GtrWindow * window)
}*/
tab = gtr_window_get_active_tab(window);
- po = gtr_tab_get_po (tab);
- if (gtr_po_get_state (po) == GTR_PO_STATE_MODIFIED)
- list = g_list_prepend (list, po);
-
+ if (tab != NULL) {
+ po = gtr_tab_get_po (tab);
+ if (gtr_po_get_state (po) == GTR_PO_STATE_MODIFIED)
+ list = g_list_prepend (list, po);
+ }
return list;
}
diff --git a/src/gtr-window.c b/src/gtr-window.c
index d0876b30..59c79baf 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -184,7 +184,7 @@ drag_data_received_cb (GtkWidget * widget,
}
}
-static void
+void
set_window_title (GtrWindow * window, gboolean with_path)
{
GtrPo *po;
@@ -226,13 +226,14 @@ set_window_title (GtrWindow * window, gboolean with_path)
title = g_strdup (_("Translation Editor"));
}
- gtk_window_set_title (GTK_WINDOW (window), title);
+ //gtk_window_set_title (GTK_WINDOW (window), title);
// notebook headerbar
header = GTK_HEADER_BAR (gtr_tab_get_header (GTR_TAB (priv->active_tab)));
gtk_header_bar_set_title (header, title);
+ gtk_widget_show_all(GTK_WIDGET(header));
- g_free (title);
+ //g_free (title);
}
static void
@@ -512,6 +513,20 @@ searchbar_toggled (GtrTab * tab, gboolean revealed, GtrWindow *window)
}
/***************************** Public funcs ***********************************/
+void
+gtr_window_remove_tab (GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ if (priv->active_tab != NULL)
+ {
+ gtk_widget_destroy(GTK_WIDGET(priv->active_tab));
+ }
+ //as set_window_title not working in gtr_window_create_tab that's why we are removing whole child of stack
and again adding it in gtr_window_create_tab
+ if (gtk_stack_get_child_by_name(priv->header_stack,"poeditor") != NULL)
+ {
+ gtk_widget_destroy(GTK_WIDGET(gtk_stack_get_child_by_name(priv->header_stack,"poeditor")));
+ }
+}
/**
* gtr_window_create_tab:
@@ -534,16 +549,15 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
// to remove the tab functionality without change all
// the code
GList *tabs, *l;
- tabs = gtr_window_get_all_tabs (window);
+ /*tabs = gtr_window_get_all_tabs (window);
for (l = tabs; l != NULL; l = g_list_next (l))
_gtr_window_close_tab (window, l->data);
- g_list_free (tabs);
+ 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
@@ -573,10 +587,14 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
gtr_notebook_reset_sort (GTR_NOTEBOOK (priv->notebook));
*/
- gtk_stack_add_named (GTK_STACK (priv->stack), GTK_WIDGET(priv->active_tab), "poeditor");
- gtk_stack_add_named (GTK_STACK (priv->header_stack),
- gtr_tab_get_header (GTR_TAB (priv->active_tab)),
- "poeditor");
+ if (gtk_stack_get_child_by_name (priv->stack,"poeditor") == NULL) {
+ gtk_stack_add_named (GTK_STACK (priv->stack), GTK_WIDGET(priv->active_tab), "poeditor");
+ }
+ if (gtk_stack_get_child_by_name (priv->header_stack,"poeditor") == NULL) {
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_tab_get_header (GTR_TAB (priv->active_tab)),
+ "poeditor");
+ }
// code view
priv->codeview = gtr_code_view_new (window);
@@ -588,6 +606,9 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
window);
g_signal_connect (tab, "searchbar-toggled", G_CALLBACK (searchbar_toggled), window);
+
+ //Don't know why this is not setting title
+ set_window_title (window, TRUE);
return tab;
}
@@ -802,17 +823,16 @@ gtr_window_get_tab_from_location (GtrWindow * window, GFile * location)
*
* Sets the active tab for the @window.
*/
-void
+/* void
gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab)
{
- /*GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
gint page;
page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), tab);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);*/
- g_printf("setting active_tab \n");
-}
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
+}*/
/**
* _gtr_window_close_tab:
@@ -822,10 +842,10 @@ gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab)
* Closes the opened @tab of the @window and sets the right sensitivity of the
* widgets.
*/
-void
+/*void
_gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
{
- /*GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
gint i;
g_return_if_fail (GTR_IS_TAB (tab));
@@ -833,8 +853,8 @@ _gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
i = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
GTK_WIDGET (tab));
if (i != -1)
- gtr_notebook_remove_page (GTR_NOTEBOOK (priv->notebook), i);*/
-}
+ gtr_notebook_remove_page (GTR_NOTEBOOK (priv->notebook), i);
+}*/
void
gtr_window_show_projects (GtrWindow *window)
@@ -865,12 +885,12 @@ gtr_window_show_dlteams (GtrWindow *window)
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "dlteams");
}
-void
+/*void
gtr_window_remove_all_pages (GtrWindow *window)
{
//GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
//gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
-}
+}*/
void
gtr_window_show_tm_dialog (GtrWindow *window)
diff --git a/src/gtr-window.h b/src/gtr-window.h
index 986e794c..862e4db2 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -67,9 +67,9 @@ GList *gtr_window_get_all_views (GtrWindow * window,
GtkWidget *gtr_window_get_tab_from_location (GtrWindow * window, GFile * location);
-void gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
+//void gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
-void _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
+//void _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
GtrTranslationMemory * gtr_window_get_tm (GtrWindow *window);
void gtr_window_show_tm_dialog (GtrWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]