[anjuta/git-shell] libanjuta: Add a basic stub implementation of AnjutaFileList



commit 19d4c62e84671523022177d2da70995cc3ca0f2a
Author: James Liggett <jrliggett cox net>
Date:   Thu Jun 17 01:02:52 2010 -0700

    libanjuta: Add a basic stub implementation of AnjutaFileList
    
    This is a new widget I'm building to make building of dialogs that operate on
    files, like VCS add and remove dialogs, more uniform and easier to write.
    When it's finished, it will allow the user to create a list of files, or file
    patterns, to operate on. Users will be able to drag from any source that
    supports GFile, or manually enter file paths into the list.

 libanjuta/Makefile.am            |    7 +-
 libanjuta/anjuta-file-list.c     |  179 ++++++++++++++++++++++++++++++++++++++
 libanjuta/anjuta-file-list.h     |   59 +++++++++++++
 libanjuta/anjuta-glade-catalog.c |    1 +
 libanjuta/anjuta-glade.xml       |    4 +
 5 files changed, 248 insertions(+), 2 deletions(-)
---
diff --git a/libanjuta/Makefile.am b/libanjuta/Makefile.am
index 8e5e4c3..c9f4bb3 100644
--- a/libanjuta/Makefile.am
+++ b/libanjuta/Makefile.am
@@ -95,7 +95,9 @@ libanjuta_la_SOURCES= \
 	anjuta-dock.c \
 	anjuta-dock.h \
 	anjuta-dock-pane.c \
-	anjuta-dock-pane.h 
+	anjuta-dock-pane.h \
+	anjuta-file-list.c \
+	anjuta-file-list.h
 
 
 if HAVE_PLUGIN_GLADE
@@ -160,7 +162,8 @@ libanjuta_include = \
 	anjuta-tabber.h \
 	anjuta-command-bar.h \
 	anjuta-dock.h \
-	anjuta-dock-pane.h
+	anjuta-dock-pane.h \
+	anjuta-file-list.h
 
 libanjutainclude_HEADERS = \
 	$(libanjuta_include) \
diff --git a/libanjuta/anjuta-file-list.c b/libanjuta/anjuta-file-list.c
new file mode 100644
index 0000000..4c4dfc3
--- /dev/null
+++ b/libanjuta/anjuta-file-list.c
@@ -0,0 +1,179 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * anjuta 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.
+ * 
+ * anjuta 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/>.
+ */
+
+#include "anjuta-file-list.h"
+
+enum
+{
+	PROP_0,
+
+	PROP_RELATIVE_PATH
+};
+
+enum
+{
+	COL_PATH,
+
+	NUM_COLS
+};
+
+struct _AnjutaFileListPriv
+{
+	gchar *relative_path;
+	GtkWidget *list_view;
+	GtkListStore *list_model;
+	GtkWidget *copy_button;
+	GtkWidget *remove_button;
+
+	/* The placeholder iter tells the user that a file can be entered into the
+	 * view, or dragged into it. */
+	GtkTreeIter placeholder;
+};
+
+G_DEFINE_TYPE (AnjutaFileList, anjuta_file_list, GTK_TYPE_VBOX);
+
+static void
+anjuta_file_list_init (AnjutaFileList *self)
+{
+	GtkWidget *scrolled_window;
+	GtkWidget *button_box;
+	GtkWidget *clear_button;
+
+	self->priv = g_new0 (AnjutaFileListPriv, 1);
+	self->priv->list_view = gtk_tree_view_new ();
+	self->priv->list_model = gtk_list_store_new (NUM_COLS, G_TYPE_STRING);
+	self->priv->copy_button = gtk_button_new_from_stock (GTK_STOCK_COPY);
+	self->priv->remove_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+
+	button_box = gtk_hbutton_box_new ();
+	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+	clear_button = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
+
+	/* File list view */
+	gtk_box_set_spacing (GTK_BOX (self), 2);
+	gtk_box_set_homogeneous (GTK_BOX (self), FALSE);
+
+	gtk_tree_view_set_model (GTK_TREE_VIEW (self->priv->list_view), 
+	                         GTK_TREE_MODEL (self->priv->list_model));
+
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+	                                                     GTK_POLICY_AUTOMATIC,
+	                                                     GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+	                                     GTK_SHADOW_IN);
+	gtk_container_add (GTK_CONTAINER (scrolled_window), self->priv->list_view);
+	gtk_box_pack_start (GTK_BOX (self), scrolled_window, TRUE, TRUE, 0);
+
+	/* Button box */
+	gtk_box_set_spacing (GTK_BOX (button_box), 5);
+
+	gtk_container_add (GTK_CONTAINER (button_box), self->priv->copy_button);
+	gtk_container_add (GTK_CONTAINER (button_box), self->priv->remove_button);
+	gtk_container_add (GTK_CONTAINER (button_box), clear_button);
+	gtk_box_pack_start (GTK_BOX (self), button_box, FALSE, FALSE, 0);
+}
+
+static void
+anjuta_file_list_finalize (GObject *object)
+{
+	/* TODO: Add deinitalization code here */
+
+	G_OBJECT_CLASS (anjuta_file_list_parent_class)->finalize (object);
+}
+
+static void
+anjuta_file_list_set_property (GObject *object, guint prop_id, 
+                               const GValue *value, GParamSpec *pspec)
+{
+	AnjutaFileList *self;
+
+	g_return_if_fail (ANJUTA_IS_FILE_LIST (object));
+
+	self = ANJUTA_FILE_LIST (object);
+
+	switch (prop_id)
+	{
+		case PROP_RELATIVE_PATH:
+			g_free (self->priv->relative_path);
+
+			self->priv->relative_path = g_value_dup_string (value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+anjuta_file_list_get_property (GObject *object, guint prop_id, GValue *value, 
+                               GParamSpec *pspec)
+{
+	AnjutaFileList *self;
+
+	g_return_if_fail (ANJUTA_IS_FILE_LIST (object));
+
+	self = ANJUTA_FILE_LIST (object);
+
+	switch (prop_id)
+	{
+		case PROP_RELATIVE_PATH:
+			g_value_set_string (value, self->priv->relative_path);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+anjuta_file_list_class_init (AnjutaFileListClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = anjuta_file_list_finalize;
+	object_class->set_property = anjuta_file_list_set_property;
+	object_class->get_property = anjuta_file_list_get_property;
+
+	g_object_class_install_property (object_class,
+	                                 PROP_RELATIVE_PATH,
+	                                 g_param_spec_string ("relative-path",
+	                                                      "relative-path",
+	                                                      _("Path that all files in the list should be relative to"),
+	                                                      "",
+	                                                      0));
+}
+
+
+GtkWidget *
+anjuta_file_list_new (void)
+{
+	return g_object_new (ANJUTA_TYPE_FILE_LIST, NULL);
+}
+
+GList *
+anjuta_file_list_anjuta_file_lst_get_paths (AnjutaFileList *self)
+{
+	return NULL;
+}
+
+void
+anjuta_file_list_set_relative_path (AnjutaFileList *self, const gchar *path)
+{
+
+}
diff --git a/libanjuta/anjuta-file-list.h b/libanjuta/anjuta-file-list.h
new file mode 100644
index 0000000..9c48ce8
--- /dev/null
+++ b/libanjuta/anjuta-file-list.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * anjuta 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.
+ * 
+ * anjuta 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/>.
+ */
+
+#ifndef _ANJUTA_FILE_LIST_H_
+#define _ANJUTA_FILE_LIST_H_
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_FILE_LIST             (anjuta_file_list_get_type ())
+#define ANJUTA_FILE_LIST(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_FILE_LIST, AnjutaFileList))
+#define ANJUTA_FILE_LIST_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_FILE_LIST, AnjutaFileListClass))
+#define ANJUTA_IS_FILE_LIST(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_FILE_LIST))
+#define ANJUTA_IS_FILE_LIST_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_FILE_LIST))
+#define ANJUTA_FILE_LIST_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_FILE_LIST, AnjutaFileListClass))
+
+typedef struct _AnjutaFileListClass AnjutaFileListClass;
+typedef struct _AnjutaFileList AnjutaFileList;
+typedef struct _AnjutaFileListPriv AnjutaFileListPriv;
+
+struct _AnjutaFileListClass
+{
+	GtkVBoxClass parent_class;
+};
+
+struct _AnjutaFileList
+{
+	GtkVBox parent_instance;
+
+	AnjutaFileListPriv *priv;
+};
+
+GType anjuta_file_list_get_type (void) G_GNUC_CONST;
+GtkWidget * anjuta_file_list_new (void);
+GList * anjuta_file_list_anjuta_file_lst_get_paths (AnjutaFileList *self);
+void anjuta_file_list_set_relative_path (AnjutaFileList *self, const gchar *path);
+
+G_END_DECLS
+
+#endif /* _ANJUTA_FILE_LIST_H_ */
diff --git a/libanjuta/anjuta-glade-catalog.c b/libanjuta/anjuta-glade-catalog.c
index 82be0db..facc522 100644
--- a/libanjuta/anjuta-glade-catalog.c
+++ b/libanjuta/anjuta-glade-catalog.c
@@ -1,3 +1,4 @@
 /* Stub file for Anjuta Glade 3 Plugin */
 #include <libanjuta/anjuta-vcs-status-tree-view.h>
 #include <libanjuta/anjuta-drop-entry.h>
+#include <libanjuta/anjuta-file-list.h>
diff --git a/libanjuta/anjuta-glade.xml b/libanjuta/anjuta-glade.xml
index 2fde8da..a37daf7 100644
--- a/libanjuta/anjuta-glade.xml
+++ b/libanjuta/anjuta-glade.xml
@@ -28,10 +28,14 @@
 
 		<glade-widget-class name="AnjutaDropEntry" title="Drop Entry"
 		 generic-name="dropentry" />
+
+		 <glade-widget-class name="AnjutaFileList" title="File List"
+		 generic-name="filelist1" />
 	</glade-widget-classes>
 
 	<glade-widget-group name="Anjuta" title="Anjuta">
 		<glade-widget-class-ref name="AnjutaVcsStatusTreeView" />
 		<glade-widget-class-ref name="AnjutaDropEntry" />
+		<glade-widget-class-ref name="AnjutaFileList" />
 	</glade-widget-group>
 </glade-catalog>



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