Introducing the directory tree plug-in
This commit is contained in:
parent
c3cc689d27
commit
e81b3ffbbf
1
Makefile
1
Makefile
|
@ -63,6 +63,7 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/src/desktopicon.h \
|
||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/src/plugins/cvs.c \
|
||||
$(PACKAGE)-$(VERSION)/src/plugins/dirtree.c \
|
||||
$(PACKAGE)-$(VERSION)/src/plugins/preview.c \
|
||||
$(PACKAGE)-$(VERSION)/src/plugins/properties.c \
|
||||
$(PACKAGE)-$(VERSION)/src/plugins/volumes.c \
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
../src/properties.c
|
||||
../src/view.c
|
||||
../src/plugins/cvs.c
|
||||
../src/plugins/dirtree.c
|
||||
../src/plugins/preview.c
|
||||
../src/plugins/properties.c
|
||||
../src/plugins/volumes.c
|
||||
|
|
6
po/de.po
6
po/de.po
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Browser 0.1.4\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-07-29 03:37+0200\n"
|
||||
"POT-Creation-Date: 2011-07-30 04:08+0200\n"
|
||||
"PO-Revision-Date: 2010-03-29 23:28+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: English\n"
|
||||
|
@ -764,6 +764,10 @@ msgstr ""
|
|||
msgid "Command exited with signal %d"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/dirtree.c:50
|
||||
msgid "Directory tree"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/preview.c:65
|
||||
msgid "Preview"
|
||||
msgstr ""
|
||||
|
|
6
po/es.po
6
po/es.po
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Browser 0.1.4\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-07-29 03:37+0200\n"
|
||||
"POT-Creation-Date: 2011-07-30 04:08+0200\n"
|
||||
"PO-Revision-Date: 2010-03-30 01:04+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: Spanish\n"
|
||||
|
@ -764,6 +764,10 @@ msgstr ""
|
|||
msgid "Command exited with signal %d"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/dirtree.c:50
|
||||
msgid "Directory tree"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/preview.c:65
|
||||
msgid "Preview"
|
||||
msgstr ""
|
||||
|
|
6
po/fr.po
6
po/fr.po
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Browser 0.1.4\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-07-29 03:37+0200\n"
|
||||
"POT-Creation-Date: 2011-07-30 04:08+0200\n"
|
||||
"PO-Revision-Date: 2010-03-29 23:28+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: French\n"
|
||||
|
@ -798,6 +798,10 @@ msgstr "La commande a terminé avec le code d'erreur %d"
|
|||
msgid "Command exited with signal %d"
|
||||
msgstr "La commande a été terminée par le signal %d"
|
||||
|
||||
#: ../src/plugins/dirtree.c:50
|
||||
msgid "Directory tree"
|
||||
msgstr "Arborescence"
|
||||
|
||||
#: ../src/plugins/preview.c:65
|
||||
msgid "Preview"
|
||||
msgstr "Prévisualisation"
|
||||
|
|
6
po/it.po
6
po/it.po
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Browser 0.1.4\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-07-29 03:37+0200\n"
|
||||
"POT-Creation-Date: 2011-07-30 04:08+0200\n"
|
||||
"PO-Revision-Date: 2010-04-07 23:18+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: Italian\n"
|
||||
|
@ -764,6 +764,10 @@ msgstr ""
|
|||
msgid "Command exited with signal %d"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/dirtree.c:50
|
||||
msgid "Directory tree"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/plugins/preview.c:65
|
||||
msgid "Preview"
|
||||
msgstr ""
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
TARGETS = cvs.so preview.so properties.so volumes.so
|
||||
TARGETS = cvs.so dirtree.so preview.so properties.so volumes.so
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
|
@ -25,6 +25,13 @@ cvs_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
|||
cvs.so: $(cvs_OBJS)
|
||||
$(LD) -o cvs.so $(cvs_OBJS) $(cvs_LDFLAGS)
|
||||
|
||||
dirtree_OBJS = dirtree.o
|
||||
dirtree_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
dirtree_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
|
||||
dirtree.so: $(dirtree_OBJS)
|
||||
$(LD) -o dirtree.so $(dirtree_OBJS) $(dirtree_LDFLAGS)
|
||||
|
||||
preview_OBJS = preview.o
|
||||
preview_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
preview_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
|
@ -49,6 +56,9 @@ volumes.so: $(volumes_OBJS)
|
|||
cvs.o: cvs.c ../../include/Browser.h
|
||||
$(CC) $(cvs_CFLAGS) -c cvs.c
|
||||
|
||||
dirtree.o: dirtree.c ../../include/Browser.h
|
||||
$(CC) $(dirtree_CFLAGS) -c dirtree.c
|
||||
|
||||
preview.o: preview.c ../../include/Browser.h
|
||||
$(CC) $(preview_CFLAGS) -c preview.c
|
||||
|
||||
|
@ -59,7 +69,7 @@ volumes.o: volumes.c ../../include/Browser.h
|
|||
$(CC) $(volumes_CFLAGS) -c volumes.c
|
||||
|
||||
clean:
|
||||
$(RM) -- $(cvs_OBJS) $(preview_OBJS) $(properties_OBJS) $(volumes_OBJS)
|
||||
$(RM) -- $(cvs_OBJS) $(dirtree_OBJS) $(preview_OBJS) $(properties_OBJS) $(volumes_OBJS)
|
||||
|
||||
distclean: clean
|
||||
$(RM) -- $(TARGETS)
|
||||
|
@ -68,6 +78,8 @@ install: $(TARGETS)
|
|||
$(MKDIR) $(DESTDIR)$(LIBDIR)/Browser/plugins
|
||||
$(INSTALL) -m 0644 -- cvs.so $(DESTDIR)$(LIBDIR)/Browser/plugins/cvs.so
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/Browser/plugins
|
||||
$(INSTALL) -m 0644 -- dirtree.so $(DESTDIR)$(LIBDIR)/Browser/plugins/dirtree.so
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/Browser/plugins
|
||||
$(INSTALL) -m 0644 -- preview.so $(DESTDIR)$(LIBDIR)/Browser/plugins/preview.so
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/Browser/plugins
|
||||
$(INSTALL) -m 0644 -- properties.so $(DESTDIR)$(LIBDIR)/Browser/plugins/properties.so
|
||||
|
@ -76,6 +88,7 @@ install: $(TARGETS)
|
|||
|
||||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Browser/plugins/cvs.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Browser/plugins/dirtree.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Browser/plugins/preview.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Browser/plugins/properties.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Browser/plugins/volumes.so
|
||||
|
|
153
src/plugins/dirtree.c
Normal file
153
src/plugins/dirtree.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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/>. */
|
||||
|
||||
|
||||
|
||||
#include <System.h>
|
||||
#include <libintl.h>
|
||||
#include "Browser.h"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
|
||||
/* Dirtree */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _Dirtree
|
||||
{
|
||||
GdkPixbuf * folder;
|
||||
GtkTreeStore * store;
|
||||
GtkWidget * view;
|
||||
} Dirtree;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static GtkWidget * _dirtree_init(BrowserPlugin * plugin);
|
||||
static void _dirtree_destroy(BrowserPlugin * plugin);
|
||||
static void _dirtree_refresh(BrowserPlugin * plugin, char const * path);
|
||||
|
||||
/* callbacks */
|
||||
static void _dirtree_on_selection_changed(gpointer data);
|
||||
|
||||
|
||||
/* public */
|
||||
/* variables */
|
||||
BrowserPlugin plugin =
|
||||
{
|
||||
NULL,
|
||||
N_("Directory tree"),
|
||||
"stock_folder",
|
||||
_dirtree_init,
|
||||
_dirtree_destroy,
|
||||
_dirtree_refresh,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* dirtree_init */
|
||||
static GtkWidget * _dirtree_init(BrowserPlugin * plugin)
|
||||
{
|
||||
Dirtree * dirtree;
|
||||
BrowserPluginHelper * helper = plugin->helper;
|
||||
GtkIconTheme * icontheme;
|
||||
GError * error = NULL;
|
||||
GtkWidget * widget;
|
||||
GtkCellRenderer * renderer;
|
||||
GtkTreeViewColumn * column;
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeIter iter;
|
||||
gint size;
|
||||
|
||||
if((dirtree = object_new(sizeof(*dirtree))) == NULL)
|
||||
return NULL;
|
||||
plugin->priv = dirtree;
|
||||
icontheme = gtk_icon_theme_get_default();
|
||||
gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &size, &size);
|
||||
dirtree->folder = gtk_icon_theme_load_icon(icontheme, "stock_folder",
|
||||
size, GTK_ICON_LOOKUP_USE_BUILTIN, &error);
|
||||
if(dirtree->folder == NULL)
|
||||
{
|
||||
helper->error(helper->browser, error->message, 1);
|
||||
g_error_free(error);
|
||||
}
|
||||
widget = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
dirtree->store = gtk_tree_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
gtk_tree_store_insert(dirtree->store, &iter, NULL, -1);
|
||||
gtk_tree_store_set(dirtree->store, &iter, 0, dirtree->folder, 1, "/",
|
||||
2, "/", -1);
|
||||
dirtree->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||
dirtree->store));
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(dirtree->view), FALSE);
|
||||
renderer = gtk_cell_renderer_pixbuf_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
|
||||
"pixbuf", 0, NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(dirtree->view), column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
|
||||
"text", 1, NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(dirtree->view), column);
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dirtree->view));
|
||||
gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect_swapped(treesel, "changed", G_CALLBACK(
|
||||
_dirtree_on_selection_changed), plugin);
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(widget),
|
||||
dirtree->view);
|
||||
gtk_widget_show_all(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
/* dirtree_destroy */
|
||||
static void _dirtree_destroy(BrowserPlugin * plugin)
|
||||
{
|
||||
Dirtree * dirtree = plugin->priv;
|
||||
|
||||
g_object_unref(dirtree->folder);
|
||||
object_delete(dirtree);
|
||||
}
|
||||
|
||||
|
||||
/* dirtree_refresh */
|
||||
static void _dirtree_refresh(BrowserPlugin * plugin, char const * path)
|
||||
{
|
||||
Dirtree * dirtree = plugin->priv;
|
||||
|
||||
/* FIXME implement */
|
||||
}
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* dirtree_on_selection_changed */
|
||||
static void _dirtree_on_selection_changed(gpointer data)
|
||||
{
|
||||
BrowserPlugin * plugin = data;
|
||||
Dirtree * dirtree = plugin->priv;
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * location;
|
||||
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dirtree->view));
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, 2, &location, -1);
|
||||
plugin->helper->set_location(plugin->helper->browser, location);
|
||||
g_free(location);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
targets=cvs,preview,properties,volumes
|
||||
targets=cvs,dirtree,preview,properties,volumes
|
||||
cppflags_force=-I ../../include
|
||||
cppflags=
|
||||
cflags_force=-W `pkg-config --cflags libDesktop`
|
||||
|
@ -13,6 +13,14 @@ install=$(LIBDIR)/Browser/plugins
|
|||
[cvs.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[dirtree]
|
||||
type=plugin
|
||||
sources=dirtree.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[dirtree.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[preview]
|
||||
type=plugin
|
||||
sources=preview.c
|
||||
|
|
Loading…
Reference in New Issue
Block a user