[gtranslator/dl-integration: 3/18] dl-integration: Add combo box



commit 9226c60fa7abcee7d41743108a0b9d692a4c393e
Author: Teja <teja cetinski gmail com>
Date:   Mon Dec 24 12:49:16 2018 +0100

    dl-integration: Add combo box
    
    Add combo box with sample/temp data, create list store, add button and
    connect signal to load combo box on click.

 src/gtr-dl-teams.c  | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/gtr-dl-teams.ui | 12 +++++++++-
 src/gtr-window.c    |  1 +
 3 files changed, 78 insertions(+), 3 deletions(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index 7f12ebb0..b40535a1 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -30,6 +30,7 @@ typedef struct
   GtkWidget *titlebar;
   GtkWidget *main_box;
   GtkWidget *open_button;
+  GtkWidget *dl_button;
 
   GtrWindow *main_window;
 } GtrDlTeamsPrivate;
@@ -41,9 +42,67 @@ struct _GtrDlTeams
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtrDlTeams, gtr_dl_teams, GTK_TYPE_BIN)
 
-
 static void team_add_cb (GtkButton *btn, GtrDlTeams *self);
 
+static GtkTreeModel *
+create_combo_store (void)
+{
+  const gchar *labels[4] = {
+    "Adding",
+    "Items",
+    "As I",
+    "Go",
+  };
+
+  //GtkTreeIter iter;
+  GtkListStore *store;
+  gint i;
+
+  store = gtk_list_store_new (1, G_TYPE_STRING);
+
+  for (i = 0; i < G_N_ELEMENTS (labels); i++)
+    {
+      //printf( labels[i]);printf("\n");
+      gtk_list_store_insert_with_values(store, NULL, -1,
+        0, "test name",
+        -1);
+      /*
+      gtk_list_store_append (store, &iter);
+      gtk_list_store_set (store, &iter,
+                          0, "Test",
+                          -1);*/
+    }
+
+  return GTK_TREE_MODEL (store);
+}
+
+static void
+add_dl_teams_combo (GtkButton *btn,
+             GtrDlTeams *self)
+{
+  GtkWidget *combo_box;
+  GtkTreeModel *model;
+  GtkCellRenderer *column;
+
+  GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
+
+  model = create_combo_store ();
+  combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
+  g_object_unref (model);
+
+  column = gtk_cell_renderer_text_new();
+  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), column, TRUE);
+
+  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), column,
+                                 "cell-background", 0,
+                                 "text", 1,
+                                 NULL);
+
+  gtk_container_add (GTK_CONTAINER (priv->main_box), combo_box);
+  gtk_widget_show (combo_box);
+
+}
+
 
 static void
 gtr_dl_teams_dispose (GObject *object)
@@ -73,12 +132,13 @@ gtr_dl_teams_class_init (GtrDlTeamsClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, main_box);
 
   gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, open_button);
+  gtk_widget_class_bind_template_child_private (widget_class, GtrDlTeams, dl_button);
 }
 
 static void
 gtr_dl_teams_init (GtrDlTeams *self)
 {
-  GtkWidget *box, *combo, *entry;
+  //GtkWidget *box, *combo, *entry;
   GtrDlTeamsPrivate *priv = gtr_dl_teams_get_instance_private (self);
   gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -88,6 +148,10 @@ gtr_dl_teams_init (GtrDlTeams *self)
                     "clicked",
                     G_CALLBACK (team_add_cb),
                     self);
+  g_signal_connect (priv->dl_button,
+                    "clicked",
+                    G_CALLBACK (add_dl_teams_combo),
+                    self);
 }
 
 GtrDlTeams*
diff --git a/src/gtr-dl-teams.ui b/src/gtr-dl-teams.ui
index 88b92349..9a120b65 100644
--- a/src/gtr-dl-teams.ui
+++ b/src/gtr-dl-teams.ui
@@ -48,7 +48,7 @@
   <!-- Header bar -->
   <object class="GtkHeaderBar" id="titlebar">
     <property name="visible">true</property>
-    <property name="title" translatable="yes">Select a PO file</property>
+    <property name="title" translatable="yes">Damned Lies integration</property>
     <property name="show_close_button">True</property>
     <style>
       <class name="titlebar"/>
@@ -63,6 +63,16 @@
         <property name="position">0</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkButton" id="dl_button">
+        <property name="label" translatable="yes">Load from DL…</property>
+        <property name="visible">true</property>
+      </object>
+      <packing>
+        <property name="pack-type">start</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkMenuButton" id="main_menu">
         <property name="visible">True</property>
diff --git a/src/gtr-window.c b/src/gtr-window.c
index f0e052ee..3cff1b9a 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -792,6 +792,7 @@ gtr_window_init (GtrWindow *window)
   gtr_translation_memory_set_max_items (priv->translation_memory, 10);
 
   gtr_window_show_dlteams (window);
+  //gtr_window_show_projects (window);
 }
 
 static void


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