[bijiben/wip/sadiq/modernize] organize-dialog: wip
- From: Mohammed Sadiq <pksadiq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben/wip/sadiq/modernize] organize-dialog: wip
- Date: Sun, 17 Dec 2017 13:22:19 +0000 (UTC)
commit c7b8ef536c0f663313296148339e7a72fabe8e54
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date: Wed Dec 13 21:01:06 2017 +0530
organize-dialog: wip
data/bjb.gresource.xml | 1 +
data/resources/organize-dialog.ui | 100 +++++++++++++++++++++++++++++
src/bjb-organize-dialog.c | 127 +++++++++++++++++++++----------------
3 files changed, 172 insertions(+), 56 deletions(-)
---
diff --git a/data/bjb.gresource.xml b/data/bjb.gresource.xml
index a7a441b..d07bfc3 100644
--- a/data/bjb.gresource.xml
+++ b/data/bjb.gresource.xml
@@ -15,6 +15,7 @@
</gresource>
<gresource prefix="/org/gnome/bijiben/ui">
+ <file alias="organize-dialog.ui" preprocess="xml-stripblanks">resources/organize-dialog.ui</file>
<file alias="settings-dialog.ui">resources/settings-dialog.ui</file>
<file alias="empty-results-box.ui">resources/empty-results-box.ui</file>
<file alias="import-dialog.ui" preprocess="xml-stripblanks">resources/import-dialog.ui</file>
diff --git a/data/resources/organize-dialog.ui b/data/resources/organize-dialog.ui
new file mode 100644
index 0000000..ae67516
--- /dev/null
+++ b/data/resources/organize-dialog.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="BjbOrganizeDialog" parent="GtkDialog">
+ <property name="title" translatable="yes">Notebooks</property>
+ <property name="default-width">480</property>
+ <property name="default-height">380</property>
+ <signal name="response" handler="gtk_widget_destroy" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="border-width">8</property>
+
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="margin-bottom">2</property>
+ <property name="label" translatable="yes">Enter a name to create a notebook</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="spacing">8</property>
+ <property name="margin-bottom">6</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">1</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ <property name="fill">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">New notebook</property>
+ </object>
+ </child>
+ </object>
+ </child> <!-- /GtkBox -->
+
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">1</property>
+ <property name="shadow-type">etched-in</property>
+ <property name="expand">1</property>
+
+ <child>
+ <object class="GtkTreeView" id="view">
+ <property name="visible">1</property>
+ <property name="model">notebook_store</property>
+ <property name="headers-visible">0</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection">
+ <property name="mode">multiple</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="enabled_column">
+ <child>
+ <object class="GtkCellRendererToggle" id="enabled_cell">
+ <property name="xalign">0.5</property>
+ <signal name="toggled" handler="on_tag_toggled" object="BjbOrganizeDialog"
swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkTreeViewColumn" id="urn">
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkTreeViewColumn" id="text">
+ <child>
+ <object class="GtkCellRendererText">
+ </object>
+ </child>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ </object>
+ </child>
+ </template>
+ <object class="GtkListStore" id="notebook_store">
+ <columns>
+ <column type="gint"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
diff --git a/src/bjb-organize-dialog.c b/src/bjb-organize-dialog.c
index 12744ba..c2a3576 100644
--- a/src/bjb-organize-dialog.c
+++ b/src/bjb-organize-dialog.c
@@ -1,5 +1,6 @@
/* bjb-note-tag-dialog.c
* Copyright (C) Pierre-Yves LUYTEN 2012 <py luyten fr>
+ * Copyright 2017 Mohammed Sadiq <sadiq sadiqpk org>
*
* bijiben is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -20,8 +21,8 @@
#include "bjb-organize-dialog.h"
#include "bjb-window-base.h"
-#define BJB_ORGANIZE_DIALOG_DEFAULT_WIDTH 460
-#define BJB_ORGANIZE_DIALOG_DEFAULT_HEIGHT 380
+/* #define BJB_ORGANIZE_DIALOG_DEFAULT_WIDTH 460 */
+/* #define BJB_ORGANIZE_DIALOG_DEFAULT_HEIGHT 380 */
/* Model for tree view */
enum {
@@ -56,12 +57,13 @@ struct _BjbOrganizeDialog
GtkWindow *window;
// widgets
- GtkWidget * entry;
- GtkTreeView * view;
+ GtkWidget *entry;
+ GtkWidget *view;
// data
+ GtkListStore *notebook_store;
GList *items;
- GtkListStore *store;
+ /* GtkListStore *store; */
GHashTable *notebooks;
// tmp when a new tag added
@@ -73,7 +75,7 @@ struct _BjbOrganizeDialog
};
-G_DEFINE_TYPE (BjbOrganizeDialog, bjb_organize_dialog, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE (BjbOrganizeDialog, bjb_organize_dialog, GTK_TYPE_DIALOG)
static void
append_notebook (BijiInfoSet *set, BjbOrganizeDialog *self)
@@ -82,7 +84,7 @@ append_notebook (BijiInfoSet *set, BjbOrganizeDialog *self)
gint item_has_tag;
GList *l;
- gtk_list_store_append (self->store, &iter);
+ gtk_list_store_append (self->notebook_store, &iter);
item_has_tag = biji_item_has_notebook (self->items->data, set->title);
/* Check if other notes have the same */
@@ -95,7 +97,7 @@ append_notebook (BijiInfoSet *set, BjbOrganizeDialog *self)
}
}
- gtk_list_store_set (self->store, &iter,
+ gtk_list_store_set (self->notebook_store, &iter,
COL_SELECTION, item_has_tag,
COL_URN, set->tracker_urn,
COL_TAG_NAME , set->title, -1);
@@ -178,10 +180,10 @@ bjb_organize_dialog_handle_tags (GHashTable *result, gpointer user_data)
{
GtkTreePath *path = NULL;
- if (bjb_get_path_for_str (GTK_TREE_MODEL (self->store), &path,
+ if (bjb_get_path_for_str (GTK_TREE_MODEL (self->notebook_store), &path,
COL_TAG_NAME, self->tag_to_scroll_to))
{
- gtk_tree_view_scroll_to_cell (self->view, path, NULL, TRUE, 0.5, 0.5);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self->view), path, NULL, TRUE, 0.5, 0.5);
gtk_tree_path_free (path);
}
@@ -195,7 +197,7 @@ update_notebooks_model_async (BjbOrganizeDialog *self)
BijiManager *manager;
manager = bjb_window_base_get_manager (GTK_WIDGET (self->window));
- gtk_list_store_clear (self->store);
+ gtk_list_store_clear (self->notebook_store);
biji_get_all_notebooks_async (manager, bjb_organize_dialog_handle_tags, self);
}
@@ -221,7 +223,7 @@ on_tag_toggled (GtkCellRendererToggle *cell,
BjbOrganizeDialog *self)
{
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeModel *model = GTK_TREE_MODEL (self->store);
+ GtkTreeModel *model = GTK_TREE_MODEL (self->notebook_store);
GtkTreeIter iter;
gint toggle_item;
gint *column;
@@ -254,7 +256,7 @@ on_tag_toggled (GtkCellRendererToggle *cell,
}
self->toggled_notebook = NULL;
- gtk_list_store_set (self->store, &iter, column, toggle_item, -1);
+ gtk_list_store_set (self->notebook_store, &iter, column, toggle_item, -1);
gtk_tree_path_free (path);
}
@@ -324,11 +326,11 @@ add_columns (GtkTreeView *view, BjbOrganizeDialog *self)
G_CALLBACK (on_tag_toggled), self);
gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
- gtk_tree_view_column_set_cell_data_func (column,
- cell_renderer,
- bjb_organize_toggle_cell_data_func,
- NULL,
- NULL);
+ /* gtk_tree_view_column_set_cell_data_func (column, */
+ /* cell_renderer, */
+ /* bjb_organize_toggle_cell_data_func, */
+ /* NULL, */
+ /* NULL); */
/* URN */
column = gtk_tree_view_column_new ();
@@ -349,20 +351,22 @@ add_columns (GtkTreeView *view, BjbOrganizeDialog *self)
static void
bjb_organize_dialog_init (BjbOrganizeDialog *self)
{
- gtk_window_set_default_size (GTK_WINDOW (self),
- BJB_ORGANIZE_DIALOG_DEFAULT_WIDTH,
- BJB_ORGANIZE_DIALOG_DEFAULT_HEIGHT);
- gtk_window_set_title (GTK_WINDOW (self), _("Notebooks"));
+ gtk_widget_init_template (GTK_WIDGET (self));
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (gtk_dialog_get_header_bar (GTK_DIALOG (self))),
TRUE);
+ /* gtk_window_set_default_size (GTK_WINDOW (self), */
+ /* BJB_ORGANIZE_DIALOG_DEFAULT_WIDTH, */
+ /* BJB_ORGANIZE_DIALOG_DEFAULT_HEIGHT); */
+ /* gtk_window_set_title (GTK_WINDOW (self), _("Notebooks")); */
- g_signal_connect_swapped (self, "response",
- G_CALLBACK (gtk_widget_destroy), self);
+ /* gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (gtk_dialog_get_header_bar (GTK_DIALOG (self))),
TRUE); */
- self->store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_INT, // notebook is active
- G_TYPE_STRING, // notebook urn
- G_TYPE_STRING); // notebook title
+ /* g_signal_connect_swapped (self, "response", */
+ /* G_CALLBACK (gtk_widget_destroy), self); */
+
+ /* self->notebook_store = gtk_list_store_new (N_COLUMNS, */
+ /* G_TYPE_INT, // notebook is active */
+ /* G_TYPE_STRING, // notebook urn */
+ /* G_TYPE_STRING); // notebook title */
}
@@ -372,47 +376,48 @@ bjb_organize_dialog_constructed (GObject *obj)
BjbOrganizeDialog *self = BJB_ORGANIZE_DIALOG (obj);
GtkWidget *hbox, *label, *new, *area, *sw;
- gtk_window_set_transient_for (GTK_WINDOW (self), self->window);
+ /* return; */
+ /* gtk_window_set_transient_for (GTK_WINDOW (self), self->window); */
- area = gtk_dialog_get_content_area (GTK_DIALOG (self));
- gtk_container_set_border_width (GTK_CONTAINER (area), 8);
+ /* area = gtk_dialog_get_content_area (GTK_DIALOG (self)); */
+ /* gtk_container_set_border_width (GTK_CONTAINER (area), 8); */
- label = gtk_label_new (_("Enter a name to create a notebook"));
- gtk_box_pack_start (GTK_BOX (area), label, FALSE, FALSE, 2);
+ /* label = gtk_label_new (_("Enter a name to create a notebook")); */
+ /* gtk_box_pack_start (GTK_BOX (area), label, FALSE, FALSE, 2); */
/* New Tag */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
- gtk_box_pack_start (GTK_BOX (area), hbox, FALSE, FALSE, 2);
+ /* hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8); */
+ /* gtk_box_pack_start (GTK_BOX (area), hbox, FALSE, FALSE, 2); */
- self->entry = gtk_entry_new();
- gtk_box_pack_start (GTK_BOX (hbox), self->entry, TRUE, TRUE, 0);
+ /* self->entry = gtk_entry_new(); */
+ /* gtk_box_pack_start (GTK_BOX (hbox), self->entry, TRUE, TRUE, 0); */
- new = gtk_button_new_with_label (_("New notebook"));
- g_signal_connect_swapped (new, "clicked", G_CALLBACK (add_new_tag), self);
+ /* new = gtk_button_new_with_label (_("New notebook")); */
+ /* g_signal_connect_swapped (new, "clicked", G_CALLBACK (add_new_tag), self); */
- gtk_box_pack_start (GTK_BOX (hbox), new, FALSE, FALSE, 2);
+ /* gtk_box_pack_start (GTK_BOX (hbox), new, FALSE, FALSE, 2); */
/* List of notebooks */
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
- GTK_SHADOW_ETCHED_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
+ /* sw = gtk_scrolled_window_new (NULL, NULL); */
+ /* gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), */
+ /* GTK_SHADOW_ETCHED_IN); */
+ /* gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), */
+ /* GTK_POLICY_AUTOMATIC, */
+ /* GTK_POLICY_AUTOMATIC); */
update_notebooks_model_async (self);
- self->view = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->store)));
- gtk_tree_view_set_headers_visible (self->view, FALSE);
- g_object_unref (self->store);
+ /* self->view = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->notebook_store))); */
+ /* gtk_tree_view_set_headers_visible (self->view, FALSE); */
+ /* g_object_unref (self->notebook_store); */
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->view),
- GTK_SELECTION_MULTIPLE);
+ /* gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->view), */
+ /* GTK_SELECTION_MULTIPLE); */
- add_columns (self->view, self);
- gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (self->view));
+ /* add_columns (GTK_TREE_VIEW (self->view), self); */
+ /* gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (self->view)); */
- gtk_box_pack_start (GTK_BOX (area), sw, TRUE, TRUE,2);
- gtk_widget_show_all (area);
+ /* gtk_box_pack_start (GTK_BOX (area), sw, TRUE, TRUE,2); */
+ /* gtk_widget_show_all (area); */
}
static void
@@ -477,6 +482,7 @@ static void
bjb_organize_dialog_class_init (BjbOrganizeDialogClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = bjb_organize_dialog_constructed;
object_class->finalize = bjb_organize_dialog_finalize;
@@ -499,6 +505,14 @@ bjb_organize_dialog_class_init (BjbOrganizeDialogClass *klass)
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/bijiben/ui/organize-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, BjbOrganizeDialog, entry);
+ gtk_widget_class_bind_template_child (widget_class, BjbOrganizeDialog, view);
+ gtk_widget_class_bind_template_child (widget_class, BjbOrganizeDialog, notebook_store);
+
+ /* gtk_widget_class_bind_template_callback (gtk_widget_class, on_color_set); */
}
void
@@ -509,6 +523,7 @@ bjb_organize_dialog_new (GtkWindow *parent,
"use-header-bar", TRUE,
"window", parent,
"items", biji_items,
+ "transient-for", parent,
NULL);
gtk_dialog_run (GTK_DIALOG (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]