[gtranslator] New widget to show the project list
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] New widget to show the project list
- Date: Wed, 12 Sep 2018 11:55:13 +0000 (UTC)
commit 554d23a986de512be42fbdf66033c7815cae997e
Author: Daniel García Moreno <danigm wadobo com>
Date: Sat Sep 8 13:41:36 2018 +0200
New widget to show the project list
src/gtr-application.c | 21 +++++
src/gtr-notebook.c | 17 +++-
src/gtr-notebook.h | 4 +-
src/gtr-notebook.ui | 111 ++++++++++++++++++++++++++
src/gtr-projects.c | 179 ++++++++++++++++++++++++++++++++++++++++++
src/gtr-projects.h | 33 ++++++++
src/gtr-projects.ui | 54 +++++++++++++
src/gtr-window.c | 177 ++++++++++++++---------------------------
src/gtr-window.h | 4 +
src/gtr-window.ui | 130 ++++--------------------------
src/gtranslator.gresource.xml | 1 +
src/meson.build | 1 +
12 files changed, 500 insertions(+), 232 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 64053ffe..c09a56c5 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -308,7 +308,28 @@ quit_activated (GSimpleAction *action,
g_application_quit (G_APPLICATION (app));
}
+static void
+save_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+ gtr_save_file_as_dialog (NULL, app->priv->active_window);
+}
+
+static void
+projects_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+ gtr_window_show_projects (app->priv->active_window);
+}
+
static GActionEntry app_entries[] = {
+ { "save", save_activated, NULL, NULL, NULL },
+ { "projects", projects_activated, NULL, NULL, NULL },
+
{ "new_window", new_window_activated, NULL, NULL, NULL },
{ "preferences", preferences_activated, NULL, NULL, NULL },
{ "help", help_activated, NULL, NULL, NULL },
diff --git a/src/gtr-notebook.c b/src/gtr-notebook.c
index 4a0a59af..72ac58a0 100644
--- a/src/gtr-notebook.c
+++ b/src/gtr-notebook.c
@@ -30,7 +30,12 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-G_DEFINE_TYPE (GtrNotebook, gtr_notebook, GTK_TYPE_NOTEBOOK)
+typedef struct
+{
+ GtkWidget *titlebar;
+} GtrNotebookPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrNotebook, gtr_notebook, GTK_TYPE_NOTEBOOK)
/* Signals */
enum
@@ -128,6 +133,8 @@ gtr_notebook_class_init (GtrNotebookClass * klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/translator/gtr-notebook.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, titlebar);
}
/***************************** Public funcs ***********************************/
@@ -231,3 +238,11 @@ gtr_notebook_get_page (GtrNotebook * notebook)
return GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), num));
}
+
+GtkWidget *
+gtr_notebook_get_header (GtrNotebook *notebook)
+{
+ GtrNotebookPrivate *priv = gtr_notebook_get_instance_private (notebook);
+ return priv->titlebar;
+}
+
diff --git a/src/gtr-notebook.h b/src/gtr-notebook.h
index 4359f79a..8d569f1f 100644
--- a/src/gtr-notebook.h
+++ b/src/gtr-notebook.h
@@ -63,7 +63,7 @@ struct _GtrNotebookClass
*/
GType gtr_notebook_get_type (void) G_GNUC_CONST;
-GtkWidget *gtr_notebook_new (void);
+GtkWidget *gtr_notebook_new ();
void gtr_notebook_add_page (GtrNotebook * notebook, GtrTab * tab);
@@ -73,5 +73,7 @@ void gtr_notebook_remove_all_pages (GtrNotebook *notebook);
GtrTab *gtr_notebook_get_page (GtrNotebook * notebook);
+GtkWidget *gtr_notebook_get_header (GtrNotebook *notebook);
+
G_END_DECLS
#endif /* __NOTEBOOK_H__ */
diff --git a/src/gtr-notebook.ui b/src/gtr-notebook.ui
index 2fda2a06..0a5b8455 100644
--- a/src/gtr-notebook.ui
+++ b/src/gtr-notebook.ui
@@ -6,4 +6,115 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
</template>
+
+ <!-- Header bar -->
+ <object class="GtkHeaderBar" id="titlebar">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes">Editing PO file</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <object class="GtkMenuButton" id="main_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="popover">main_menu_popover</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ </child>
+ <accessibility>
+ </accessibility>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-room_menu_button">
+ <property name="AtkObject::accessible_name" translatable="yes">Room Menu</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+
+ <!-- Menu -->
+ <object class="GtkPopoverMenu" id="main_menu_popover">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkModelButton" id="save_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.save</property>
+ <property name="text" translatable="yes">Save</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="pref_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.preferences</property>
+ <property name="text" translatable="yes">Preferences</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="open_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.projects</property>
+ <property name="text" translatable="yes">Open</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="submenu">main</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+
</interface>
+
diff --git a/src/gtr-projects.c b/src/gtr-projects.c
new file mode 100644
index 00000000..c48b8cab
--- /dev/null
+++ b/src/gtr-projects.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2018 Daniel Garcia Moreno <danigm gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-actions.h"
+#include "gtr-projects.h"
+#include "gtr-window.h"
+
+typedef struct
+{
+ GtkRecentManager *recent_manager;
+ GtkWidget *titlebar;
+ GtkWidget *main_box;
+ GtkWidget *project_list;
+ GtkWidget *open_button;
+
+ GtrWindow *main_window;
+} GtrProjectsPrivate;
+
+struct _GtrProjects
+{
+ GtkBin parent_instance;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrProjects, gtr_projects, GTK_TYPE_BIN)
+
+
+static void project_add_cb (GtkButton *btn, GtrProjects *self);
+static void init_recent (GtrProjects *self);
+
+
+static void
+gtr_projects_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_projects_parent_class)->dispose (object);
+}
+
+static void
+gtr_projects_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_projects_parent_class)->finalize (object);
+}
+
+static void
+gtr_projects_class_init (GtrProjectsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gtr_projects_finalize;
+ object_class->dispose = gtr_projects_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/translator/gtr-projects.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrProjects, titlebar);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrProjects, main_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrProjects, project_list);
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrProjects, open_button);
+}
+
+static void
+gtr_projects_init (GtrProjects *self)
+{
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ priv->main_window = NULL;
+ priv->recent_manager = gtk_recent_manager_get_default ();
+
+ init_recent (self);
+
+ g_signal_connect (priv->open_button,
+ "clicked",
+ G_CALLBACK (project_add_cb),
+ self);
+}
+
+GtrProjects*
+gtr_projects_new (GtrWindow *window) {
+ GtrProjects *self = g_object_new (GTR_TYPE_PROJECTS, NULL);
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+
+ priv->main_window = window;
+ return self;
+}
+
+GtkWidget *
+gtr_projects_get_header (GtrProjects *self)
+{
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+ return priv->titlebar;
+}
+
+// static functions
+static void
+file_open_cb (GtkListBox *box,
+ GtkListBoxRow *row,
+ gpointer data)
+{
+ gint index = gtk_list_box_row_get_index (row);
+ GtrProjects *self = GTR_PROJECTS (data);
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+
+ GList *recents = gtk_recent_manager_get_items (priv->recent_manager);
+ GtkRecentInfo *info = g_list_nth_data (recents, index);
+
+ GError *error;
+ GFile *file;
+
+ file = g_file_new_for_uri (gtk_recent_info_get_uri (info));
+ if (!gtr_open (file, priv->main_window, &error)) {
+ g_error_free (error);
+ goto out;
+ }
+
+ gtr_window_show_poeditor (priv->main_window);
+
+out:
+ g_object_unref (file);
+ g_list_free_full (recents, (GDestroyNotify)gtk_recent_info_unref);
+}
+
+static void
+project_add_cb (GtkButton *btn,
+ GtrProjects *self)
+{
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+ GtrWindow *window = GTR_WINDOW (priv->main_window);
+ gtr_open_file_dialog (NULL, window);
+}
+
+static void
+init_recent (GtrProjects *self)
+{
+ GtrProjectsPrivate *priv = gtr_projects_get_instance_private (self);
+ GtkListBox *list = GTK_LIST_BOX (priv->project_list);
+
+ GList *recents = gtk_recent_manager_get_items (priv->recent_manager);
+ GList *it = g_list_first (recents);
+ while (it)
+ {
+ const gchar *name = gtk_recent_info_get_uri_display (it->data);
+ GtkWidget *label = gtk_label_new (name);
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 6);
+
+ gtk_widget_show_all (box);
+ gtk_list_box_insert (list, box, -1);
+ it = g_list_next (it);
+ }
+
+ g_signal_connect (list, "row-activated", G_CALLBACK (file_open_cb), self);
+
+ g_list_free_full (recents, (GDestroyNotify)gtk_recent_info_unref);
+}
+
diff --git a/src/gtr-projects.h b/src/gtr-projects.h
new file mode 100644
index 00000000..770608fd
--- /dev/null
+++ b/src/gtr-projects.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 Daniel Garcia Moreno <danigm gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_PROJECTS (gtr_projects_get_type())
+
+G_DECLARE_FINAL_TYPE (GtrProjects, gtr_projects, GTR, PROJECTS, GtkBin)
+
+GtrProjects* gtr_projects_new ();
+GtkWidget* gtr_projects_get_header (GtrProjects *self);
+
+G_END_DECLS
+
diff --git a/src/gtr-projects.ui b/src/gtr-projects.ui
new file mode 100644
index 00000000..069495fb
--- /dev/null
+++ b/src/gtr-projects.ui
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtrProjects" parent="GtkBin">
+ <child>
+ <object class="GtkBox" id="main_box">
+ <property name="margin_start">134</property>
+ <property name="margin_end">134</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">24</property>
+ <property name="margin_bottom">24</property>
+ <property name="vexpand">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame" id="project_frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkListBox" id="project_list">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+
+ <!-- Header bar -->
+ <object class="GtkHeaderBar" id="titlebar">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes">Select a PO file</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <object class="GtkButton" id="open_button">
+ <property name="label" translatable="yes">Open…</property>
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+
+</interface>
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 0694fe78..bf63840d 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -33,6 +33,7 @@
#include "gtr-notebook.h"
#include "gtr-tab.h"
#include "gtr-po.h"
+#include "gtr-projects.h"
#include "gtr-settings.h"
#include "gtr-statusbar.h"
#include "gtr-utils.h"
@@ -58,18 +59,17 @@
typedef struct
{
- GtkRecentManager *recent_manager;
GSettings *state_settings;
GtkWidget *header_bar;
GtkWidget *main_box;
- GtkWidget *stack;
- GtkWidget *project_add;
- GtkWidget *project_list;
- GtkWidget *project_remove;
+ GtkWidget *header_stack;
+ GtkWidget *stack;
+ GtkWidget *projects;
GtkWidget *notebook;
+
GtrTab *active_tab;
GtkWidget *statusbar;
@@ -190,54 +190,6 @@ get_drop_window (GtkWidget * widget)
return GTR_WINDOW (target_window);
}
-static void
-show_notebook (GtrWindow *window) {
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "notebook");
-}
-
-static void
-file_open_cb (GtkListBox *box,
- GtkListBoxRow *row,
- gpointer data)
-{
- gint index = gtk_list_box_row_get_index (row);
- GtrWindow *window = GTR_WINDOW (data);
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
- GList *recents = gtk_recent_manager_get_items (priv->recent_manager);
- GtkRecentInfo *info = g_list_nth_data (recents, index);
-
- GError *error;
- GFile *file;
-
- file = g_file_new_for_uri (gtk_recent_info_get_uri (info));
- if (!gtr_open (file, window, &error)) {
- g_error_free (error);
- goto out;
- }
-
- show_notebook (window);
-
-out:
- g_object_unref (file);
- g_list_free_full (recents, (GDestroyNotify)gtk_recent_info_unref);
-}
-
-static void
-project_add_cb (GtkButton *btn,
- gpointer data)
-{
- GtrWindow *window = GTR_WINDOW (data);
- gtr_open_file_dialog (NULL, window);
-}
-
-static void
-project_remove_cb (GtkButton *btn,
- gpointer data)
-{
- printf ("PROJECT REMOVE\n");
-}
-
/* Handle drops on the GtrWindow */
static void
drag_data_received_cb (GtkWidget * widget,
@@ -516,37 +468,6 @@ fill_profile_combo (GtrWindow *window)
}
}
-static void
-init_recent (GtrWindow *window)
-{
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
- GtkListBox *list = GTK_LIST_BOX (priv->project_list);
-
- GList *recents = gtk_recent_manager_get_items (priv->recent_manager);
- GList *it = g_list_first (recents);
- while (it)
- {
- const gchar *name = gtk_recent_info_get_uri_display (it->data);
- GtkWidget *label = gtk_label_new (name);
- GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_label_set_yalign (GTK_LABEL (label), 0.5);
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 6);
-
- gtk_widget_show_all (box);
- gtk_list_box_insert (list, box, -1);
- it = g_list_next (it);
- }
-
- g_signal_connect (list,
- "row-activated",
- G_CALLBACK (file_open_cb), window);
-
-
- g_list_free_full (recents, (GDestroyNotify)gtk_recent_info_unref);
-}
-
static void
init_statusbar (GtrWindow *window)
{
@@ -700,7 +621,6 @@ gtr_window_init (GtrWindow *window)
GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
- priv->recent_manager = gtk_recent_manager_get_default ();
gtk_widget_init_template (GTK_WIDGET (window));
@@ -719,26 +639,6 @@ gtr_window_init (GtrWindow *window)
/* statusbar & progress bar */
init_statusbar (window);
- /* init recent projects */
- init_recent (window);
-
-
- priv->notebook = GTK_WIDGET (gtr_notebook_new ());
- gtk_widget_show (priv->notebook);
- g_signal_connect (priv->notebook, "switch-page",
- G_CALLBACK (notebook_switch_page), window);
- g_signal_connect (priv->notebook, "page-added",
- G_CALLBACK (notebook_tab_added), window);
- g_signal_connect (priv->notebook, "page-removed",
- G_CALLBACK (notebook_page_removed), window);
- g_signal_connect (priv->notebook,
- "tab_close_request",
- G_CALLBACK (notebook_tab_close_request), window);
-
- gtk_stack_add_named (GTK_STACK (priv->stack),
- priv->notebook,
- "notebook");
-
/* Drag and drop support, set targets to NULL because we add the
default uri_targets below */
gtk_drag_dest_set (GTK_WIDGET (window),
@@ -763,14 +663,41 @@ gtr_window_init (GtrWindow *window)
"drag_data_received",
G_CALLBACK (drag_data_received_cb), NULL);
- g_signal_connect (priv->project_add,
- "clicked",
- G_CALLBACK (project_add_cb),
- (gpointer)window);
- g_signal_connect (priv->project_remove,
- "clicked",
- G_CALLBACK (project_remove_cb),
- (gpointer)window);
+ /**
+ * Here we define different widgets that provides to append to the main
+ * stack and this widgets can also provide a custom headerbar
+ *
+ * With this widgets we have different views in the same window
+ */
+
+ // poeditor
+ priv->notebook = GTK_WIDGET (gtr_notebook_new (window));
+ gtk_widget_show (priv->notebook);
+ g_signal_connect (priv->notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page), window);
+ g_signal_connect (priv->notebook, "page-added",
+ G_CALLBACK (notebook_tab_added), window);
+ g_signal_connect (priv->notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed), window);
+ g_signal_connect (priv->notebook,
+ "tab_close_request",
+ G_CALLBACK (notebook_tab_close_request), window);
+
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->notebook, "poeditor");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)),
+ "poeditor");
+
+ // project selection
+ priv->projects = GTK_WIDGET (gtr_projects_new (window));
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->projects, "projects");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_projects_get_header (GTR_PROJECTS (priv->projects)),
+ "projects");
+
+ gtk_widget_show_all (priv->stack);
+
+ gtr_window_show_projects (window);
}
static void
@@ -840,10 +767,7 @@ gtr_window_class_init (GtrWindowClass *klass)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, header_bar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, main_box);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, stack);
-
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, project_list);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, project_add);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, project_remove);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, header_stack);
}
/***************************** Public funcs ***********************************/
@@ -1130,3 +1054,22 @@ _gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
(priv->statusbar));
}
}
+
+void
+gtr_window_show_projects (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "projects");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "projects");
+}
+
+void
+gtr_window_show_poeditor (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "poeditor");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "poeditor");
+}
+
diff --git a/src/gtr-window.h b/src/gtr-window.h
index bfcd3d7d..70aa954c 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -81,5 +81,9 @@ void gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
void _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
+/** stack app states **/
+void gtr_window_show_projects (GtrWindow *window);
+void gtr_window_show_poeditor (GtrWindow *window);
+
G_END_DECLS
#endif /* __GTR_WINDOW_H__ */
diff --git a/src/gtr-window.ui b/src/gtr-window.ui
index 759c16db..c43af06a 100644
--- a/src/gtr-window.ui
+++ b/src/gtr-window.ui
@@ -2,21 +2,11 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.14"/>
- <object class="GtkImage" id="add_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">list-add-symbolic</property>
- </object>
<object class="GtkImage" id="menu_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
- <object class="GtkImage" id="remove_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">list-remove-symbolic</property>
- </object>
<template class="GtrWindow" parent="GtkApplicationWindow">
<property name="height_request">600</property>
<property name="can_focus">False</property>
@@ -24,21 +14,28 @@
<property name="default_height">600</property>
<property name="show_menubar">False</property>
<child type="titlebar">
- <object class="GtkHeaderBar" id="header_bar">
+ <object class="GtkStack" id="header_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="title" translatable="yes">Projects</property>
- <property name="show_close_button">True</property>
+ <property name="vexpand">True</property>
<child>
- <object class="GtkMenuButton" id="menu_button">
+ <object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="receives_default">False</property>
- <property name="image">menu_image</property>
+ <property name="title" translatable="yes">Gtranslator</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <property name="image">menu_image</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
</child>
</object>
</child>
@@ -52,100 +49,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
- <child>
- <object class="GtkBox" id="projects">
- <property name="margin_start">134</property>
- <property name="margin_end">134</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">24</property>
- <property name="margin_bottom">24</property>
- <property name="vexpand">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkFrame" id="project_frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkListBox" id="project_list">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar" id="project_toolbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="toolbar_style">icons</property>
- <property name="show_arrow">False</property>
- <property name="icon_size">1</property>
- <child>
- <object class="GtkToolItem" id="project_add_remove_item">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkBox" id="project_add_remove_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="project_add">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">add_image</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="project_remove">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">remove_image</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <style>
- <class name="inline-toolbar"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="name">projects</property>
- <property name="title" translatable="yes">Projects</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -157,3 +60,4 @@
</child>
</template>
</interface>
+
diff --git a/src/gtranslator.gresource.xml b/src/gtranslator.gresource.xml
index 0a940d0d..355b7260 100644
--- a/src/gtranslator.gresource.xml
+++ b/src/gtranslator.gresource.xml
@@ -15,5 +15,6 @@
<file preprocess="xml-stripblanks">gtr-statusbar.ui</file>
<file preprocess="xml-stripblanks">gtr-tab.ui</file>
<file preprocess="xml-stripblanks">gtr-window.ui</file>
+ <file preprocess="xml-stripblanks">gtr-projects.ui</file>
</gresource>
</gresources>
diff --git a/src/meson.build b/src/meson.build
index ed7d7a1c..f500d6b6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -50,6 +50,7 @@ sources = files(
'gtr-tab-label.c',
'gtr-utils.c',
'gtr-view.c',
+ 'gtr-projects.c',
'gtr-window.c'
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]