Commit 060b5ef1 authored by Ross Golder's avatar Ross Golder

Changes to fix problems switching between notebook pages.

parent dca692e7
2006-02-07 Ross Golder <ross@golder.org>
* parse.c: Ensure that correct tab is focussed when file is opened.
* gui.c: Add callback to set current_page on page switch.
* message.c: Add 'gtranslator_message_translation_update' method.
* page.[ch]: Add 'gtranslator_page_dirty' method.
......
......@@ -94,6 +94,11 @@ static void selection_get_handler(GtkWidget *widget,
guint time_stamp, gpointer data);
#endif /* REDUNDANT */
/*
* Defined later
*/
void gtranslator_gui_switch_page(GtkNotebook *notebook, GtkNotebookPage *notebook_page, guint pagenum, gpointer user_data);
/*
* The target formats
*/
......@@ -201,6 +206,9 @@ void gtranslator_create_main_window(void)
notebook_widget = GTK_WIDGET(gtk_notebook_new());
gnome_app_set_contents(GNOME_APP(gtranslator_application), notebook_widget);
/* Add a callback to set 'current_page' on a tab change */
g_signal_connect(notebook_widget, "switch-page", G_CALLBACK(gtranslator_gui_switch_page), NULL);
/*
* Resize the window accordingly
*/
......@@ -795,6 +803,38 @@ GtkWidget *gtranslator_gui_new_page(GtrPo *po)
return current_page->content_pane;
}
/*
* Notebook callback used whenever the page is changed
*/
void gtranslator_gui_switch_page(GtkNotebook *notebook, GtkNotebookPage *notebook_page, guint pagenum, gpointer user_data) {
GList *pagelist;
GtrPage *page;
/*
* Set the 'current_page' global pointer, so the right widgets/files_added
* get updated etc.
*/
pagelist = pages;
while(pagelist) {
page = (GtrPage*)pagelist->data;
if(page->num == pagenum) {
current_page = page;
break;
}
pagelist = pagelist->next;
}
/*
* Set 'save' and 'revert' etc.
*/
if(current_page->po->file_changed) {
gtranslator_actions_enable(ACT_SAVE, ACT_REVERT, ACT_UNDO);
}
else {
gtranslator_actions_disable(ACT_SAVE, ACT_REVERT, ACT_UNDO);
}
}
/*
* Update the progress bar
*/
......
......@@ -320,6 +320,7 @@ gboolean gtranslator_open(const gchar *filename, GError **error)
if(!strcmp(page->po->filename, filename)) {
/* Tell user and maybe active that tab */
g_warning("File '%s' is already open.", page->po->filename);
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_widget), page->num);
return TRUE;
}
pagelist = pagelist->next;
......@@ -361,26 +362,25 @@ gboolean gtranslator_open(const gchar *filename, GError **error)
page = gtranslator_page_new(po);
pages = g_list_append(pages, (gpointer)page);
/*
* Make this our current page
*/
current_page = page;
/*
* Create a notebook page to display it in the GUI
*/
page_label = gtk_label_new(po->filename);
if(GtrPreferences.show_messages_table) {
current_page->num = gtk_notebook_append_page(GTK_NOTEBOOK(notebook_widget),
current_page->table_pane, page_label);
page->num = gtk_notebook_append_page(GTK_NOTEBOOK(notebook_widget),
page->table_pane, page_label);
}
else {
current_page->num = gtk_notebook_append_page(GTK_NOTEBOOK(notebook_widget),
current_page->content_pane, page_label);
page->num = gtk_notebook_append_page(GTK_NOTEBOOK(notebook_widget),
page->content_pane, page_label);
}
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_widget), current_page->num);
gtk_widget_show_all(notebook_widget);
gtk_widget_show_all(notebook_widget);
/*
* Switch to that page
*/
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_widget), page->num);
#ifdef HOLD_ON_A_SEC
/*
* Set window title
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment