[gtranslator/dl-integration: 1/18] dl-integration: Add teams widget, open on start
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/dl-integration: 1/18] dl-integration: Add teams widget, open on start
- Date: Sat, 23 Mar 2019 09:27:23 +0000 (UTC)
commit d2cd972df6b025b37fbb4627e20d56930c720e30
Author: Teja <teja cetinski gmail com>
Date: Tue Dec 18 10:05:25 2018 +0100
dl-integration: Add teams widget, open on start
Add gtr-dl-teams header, source and UI files. Include in resource XML
and meson build file. Add function to show the widget and call on start.
src/gtr-dl-teams.c | 117 +++++++++++++++++++++++++
src/gtr-dl-teams.h | 36 ++++++++
src/gtr-dl-teams.ui | 195 ++++++++++++++++++++++++++++++++++++++++++
src/gtr-window.c | 20 ++++-
src/gtr-window.h | 1 +
src/gtranslator.gresource.xml | 1 +
src/meson.build | 1 +
7 files changed, 370 insertions(+), 1 deletion(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
new file mode 100644
index 00000000..75fa1dc7
--- /dev/null
+++ b/src/gtr-dl-teams.c
@@ -0,0 +1,117 @@
+/*
+ * 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-dl-teams.h"
+#include "gtr-window.h"
+#include "gtr-utils.h"
+
+typedef struct
+{
+ GtkWidget *titlebar;
+ GtkWidget *main_box;
+ GtkWidget *open_button;
+
+ GtrWindow *main_window;
+} GtrDlTeamsPrivate;
+
+struct _GtrDlTeams
+{
+ GtkBin parent_instance;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrDlTeams, gtr_dl_teams, GTK_TYPE_BIN)
+
+
+static void team_add_cb (GtkButton *btn, GtrDlTeams *self);
+
+
+static void
+gtr_dl_teams_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_dl_teams_parent_class)->dispose (object);
+}
+
+static void
+gtr_dl_teams_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_dl_teams_parent_class)->finalize (object);
+}
+
+static void
+gtr_dl_teams_class_init (GtrDlTeamsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gtr_dl_teams_finalize;
+ object_class->dispose = gtr_dl_teams_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/translator/gtr-dl-teams.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, titlebar);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, main_box);
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, open_button);
+}
+
+static void
+gtr_dl_teams_init (GtrDlTeams *self)
+{
+ GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ priv->main_window = NULL;
+
+ g_signal_connect (priv->open_button,
+ "clicked",
+ G_CALLBACK (team_add_cb),
+ self);
+}
+
+GtrDlTeams*
+gtr_dl_teams_new (GtrWindow *window) {
+ GtrDlTeams *self = g_object_new (GTR_TYPE_DL_TEAMS, NULL);
+ GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
+
+ priv->main_window = window;
+ return self;
+}
+
+GtkWidget *
+gtr_dl_teams_get_header (GtrDlTeams *self)
+{
+ GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
+ return priv->titlebar;
+}
+
+// static functions
+static void
+team_add_cb (GtkButton *btn,
+ GtrDlTeams *self)
+{
+ GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
+ GtrWindow *window = GTR_WINDOW (priv->main_window);
+ gtr_open_file_dialog (NULL, window);
+}
+
diff --git a/src/gtr-dl-teams.h b/src/gtr-dl-teams.h
new file mode 100644
index 00000000..af38f211
--- /dev/null
+++ b/src/gtr-dl-teams.h
@@ -0,0 +1,36 @@
+/*
+ * 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_DL_TEAMS (gtr_dl_teams_get_type())
+
+G_DECLARE_FINAL_TYPE (GtrDlTeams, gtr_dl_teams, GTR, DL_TEAMS, GtkBin)
+
+GtrDlTeams* gtr_dl_teams_new ();
+GtkWidget* gtr_dl_teams_get_header (GtrDlTeams *self);
+void gtr_dl_teams_recent_add (GtrDlTeams *self,
+ GFile *location,
+ gchar *jkkproject_id);
+
+G_END_DECLS
+
diff --git a/src/gtr-dl-teams.ui b/src/gtr-dl-teams.ui
new file mode 100644
index 00000000..88b92349
--- /dev/null
+++ b/src/gtr-dl-teams.ui
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtrDlTeams" 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="valign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">14</property>
+
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">80</property>
+ <property name="icon_name">go-home-symbolic</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">O hello, my new team container!</property>
+ </object>
+ <packing>
+ <property name="expand">False</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>
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <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>
+ <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>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="main_menu-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes">Main Menu</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+
+ <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="new_win">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.new_window</property>
+ <property name="text" translatable="yes">New window</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_button1">
+ <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="pref_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.shortcuts</property>
+ <property name="text" translatable="yes">Keyboard Shortcuts</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="about_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.about</property>
+ <property name="text" translatable="yes">About</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="quit">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.quit</property>
+ <property name="text" translatable="yes">Quit</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="submenu">main</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+
+</interface>
+
diff --git a/src/gtr-window.c b/src/gtr-window.c
index df9a78f0..f0e052ee 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -34,6 +34,7 @@
#include "gtr-tab.h"
#include "gtr-po.h"
#include "gtr-projects.h"
+#include "gtr-dl-teams.h"
#include "gtr-settings.h"
#include "gtr-statusbar.h"
#include "gtr-utils.h"
@@ -75,6 +76,7 @@ typedef struct
GtkWidget *projects;
GtkWidget *notebook;
+ GtkWidget *dlteams;
GtrTab *active_tab;
@@ -769,6 +771,13 @@ gtr_window_init (GtrWindow *window)
gtr_projects_get_header (GTR_PROJECTS (priv->projects)),
"projects");
+ // DL team selection
+ priv->dlteams = GTK_WIDGET (gtr_dl_teams_new (window));
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->dlteams, "dlteams");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_dl_teams_get_header (GTR_DL_TEAMS (priv->dlteams)),
+ "dlteams");
+
gtk_widget_show_all (priv->stack);
// translation memory
@@ -782,7 +791,7 @@ gtr_window_init (GtrWindow *window)
"max-length-diff"));
gtr_translation_memory_set_max_items (priv->translation_memory, 10);
- gtr_window_show_projects (window);
+ gtr_window_show_dlteams (window);
}
static void
@@ -1171,6 +1180,15 @@ gtr_window_show_poeditor (GtrWindow *window)
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "poeditor");
}
+void
+gtr_window_show_dlteams (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "dlteams");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "dlteams");
+}
+
void
gtr_window_remove_all_pages (GtrWindow *window)
{
diff --git a/src/gtr-window.h b/src/gtr-window.h
index 63ea2051..492b351e 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -91,6 +91,7 @@ void gtr_window_tm_keybind (GtrWindow *window, GSimpleAction *action);
/** stack app states **/
void gtr_window_show_projects (GtrWindow *window);
void gtr_window_show_poeditor (GtrWindow *window);
+void gtr_window_show_dlteams (GtrWindow *window);
G_END_DECLS
#endif /* __GTR_WINDOW_H__ */
diff --git a/src/gtranslator.gresource.xml b/src/gtranslator.gresource.xml
index b67c3071..23f4841e 100644
--- a/src/gtranslator.gresource.xml
+++ b/src/gtranslator.gresource.xml
@@ -17,6 +17,7 @@
<file preprocess="xml-stripblanks">gtr-tab.ui</file>
<file preprocess="xml-stripblanks">gtr-window.ui</file>
<file preprocess="xml-stripblanks">gtr-projects.ui</file>
+ <file preprocess="xml-stripblanks">gtr-dl-teams.ui</file>
<file preprocess="xml-stripblanks">gtr-lang-button.ui</file>
<file preprocess="xml-stripblanks">help-overlay.ui</file>
</gresource>
diff --git a/src/meson.build b/src/meson.build
index 7274aa66..951dff5d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -62,6 +62,7 @@ sources = files(
'gtr-utils.c',
'gtr-view.c',
'gtr-projects.c',
+ 'gtr-dl-teams.c',
'gtr-lang-button.c',
'gtr-progress.c',
'gtr-window.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]