[Xfce4-commits] r23337 - xarchiver/branches/xarchiver-psybsd/src
Stephan Arts
stephan at xfce.org
Tue Oct 10 13:32:21 UTC 2006
Author: stephan
Date: 2006-10-10 13:32:20 +0000 (Tue, 10 Oct 2006)
New Revision: 23337
Added:
xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
xarchiver/branches/xarchiver-psybsd/src/tool_bar.h
Removed:
xarchiver/branches/xarchiver-psybsd/src/path_bar.c
xarchiver/branches/xarchiver-psybsd/src/path_bar.h
Modified:
xarchiver/branches/xarchiver-psybsd/src/Makefile.am
xarchiver/branches/xarchiver-psybsd/src/archive_store.c
xarchiver/branches/xarchiver-psybsd/src/main_window.c
xarchiver/branches/xarchiver-psybsd/src/main_window.h
xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c
xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h
Log:
Added toolbar
Modified: xarchiver/branches/xarchiver-psybsd/src/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/Makefile.am 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/Makefile.am 2006-10-10 13:32:20 UTC (rev 23337)
@@ -4,7 +4,7 @@
main.c main.h \
main_window.c main_window.h \
navigation_bar.c navigation_bar.h \
- path_bar.c path_bar.h \
+ tool_bar.c tool_bar.h \
archive_store.c archive_store.h \
archive_tree_store.c archive_tree_store.h \
preferences_dialog.c preferences_dialog.h \
Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-10 13:32:20 UTC (rev 23337)
@@ -1046,6 +1046,8 @@
gtk_tree_path_free(path_);
}
+
+ g_signal_emit(store, xa_archive_store_signals[0], 0,NULL);
}
/*
gchar *
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-10 13:32:20 UTC (rev 23337)
@@ -28,7 +28,7 @@
#include "archive_store.h"
#include "archive_tree_store.h"
#include "navigation_bar.h"
-#include "path_bar.h"
+#include "tool_bar.h"
#include "main_window.h"
#include "new_dialog.h"
#include "extract_dialog.h"
@@ -223,7 +223,8 @@
g_signal_connect(G_OBJECT(window->toolbar.tool_item_open), "clicked", G_CALLBACK(cb_xa_main_open_archive), window);
/* Action pane */
- window->toolbar.tool_item_add = gtk_tool_button_new_from_stock("gtk-go-up");
+ tmp_image = xa_main_window_find_image("add.png", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ window->toolbar.tool_item_add = gtk_tool_button_new(tmp_image, _("Add"));
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add), FALSE);
tmp_image = xa_main_window_find_image("extract.png", GTK_ICON_SIZE_LARGE_TOOLBAR);
@@ -252,7 +253,7 @@
g_signal_connect(G_OBJECT(window->toolbar.tool_item_stop), "clicked", G_CALLBACK(cb_xa_main_stop_archive), window);
- window->navigationbar = xa_path_bar_new();
+/* window->navigationbar = xa_tool_bar_new(NULL);*/
/* main view */
window->scrollwindow = gtk_scrolled_window_new(NULL, NULL);
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-10-10 13:32:20 UTC (rev 23337)
@@ -66,14 +66,18 @@
GtkWidget *menu_item_close;
GtkWidget *menu_item_quit;
+ GtkWidget *menu_item_view;
+ GtkWidget *menu_view;
+ /* contents of 'view' menu */
+ GtkWidget *menu_location_selector;
+ GtkWidget *menu_item_settings;
+
GtkWidget *menu_item_action;
GtkWidget *menu_action;
-
/* contents of 'action' menu */
GtkWidget *menu_item_add;
GtkWidget *menu_item_extract;
GtkWidget *menu_item_remove;
- GtkWidget *menu_item_settings;
GtkWidget *menu_item_help;
GtkWidget *menu_help;
Modified: xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c 2006-10-10 13:32:20 UTC (rev 23337)
@@ -68,16 +68,22 @@
static void
xa_navigation_bar_init(XANavigationBar *navigation_bar)
{
+ navigation_bar->_cb_pwd_changed = (GCallback)cb_xa_navigation_bar_pwd_changed;
+ navigation_bar->max_history = 10;
}
void
xa_navigation_bar_set_store(XANavigationBar *navigation_bar, XAArchiveStore *store)
{
- g_return_if_fail(XA_IS_ARCHIVE_STORE(store));
- g_return_if_fail(XA_IS_NAVIGATION_BAR(navigation_bar));
+ if(store)
+ {
+ g_return_if_fail(XA_IS_ARCHIVE_STORE(store));
+ g_return_if_fail(XA_IS_NAVIGATION_BAR(navigation_bar));
+ }
navigation_bar->store = store;
- g_signal_connect(G_OBJECT(store), "xa_pwd_changed", (GCallback)cb_xa_navigation_bar_pwd_changed, navigation_bar);
+ if(store)
+ g_signal_connect(G_OBJECT(store), "xa_pwd_changed", (GCallback)navigation_bar->_cb_pwd_changed, navigation_bar);
}
GtkWidget *
@@ -96,6 +102,24 @@
static void
cb_xa_navigation_bar_pwd_changed(XAArchiveStore *store, XANavigationBar *bar)
{
- g_print("PWD: %s\n", xa_archive_store_get_pwd(store));
+ gchar *path = xa_archive_store_get_pwd(store);
+ xa_navigation_bar_history_push(bar, path);
+ g_free(path);
}
+void
+xa_navigation_bar_history_push(XANavigationBar *nav_bar, gchar *path)
+{
+ nav_bar->history = g_list_prepend(nav_bar->history, g_strdup(path));
+ if(g_list_length(nav_bar->history) > nav_bar->max_history)
+ {
+ GList *last = g_list_last(nav_bar->history);
+ nav_bar->history = g_list_remove(nav_bar->history, last->data);
+ }
+}
+
+gint
+xa_navigation_bar_history_get_length(XANavigationBar *nav_bar)
+{
+ return g_list_length(nav_bar->history);
+}
Modified: xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h 2006-10-10 11:55:11 UTC (rev 23336)
+++ xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h 2006-10-10 13:32:20 UTC (rev 23337)
@@ -46,6 +46,10 @@
{
GtkToolbar parent;
XAArchiveStore *store;
+ GList *history;
+ GList *pwd;
+ gint max_history;
+ GCallback _cb_pwd_changed;
};
typedef struct _XANavigationBarClass XANavigationBarClass;
@@ -57,7 +61,9 @@
GType xa_navigation_bar_get_type();
GtkWidget *xa_navigation_bar_new();
-void xa_navigation_bar_set_store(XANavigationBar *navigation_bar, XAArchiveStore *store);
+void xa_navigation_bar_history_push(XANavigationBar *nav_bar, gchar *path);
+void xa_navigation_bar_set_store(XANavigationBar *navigation_bar, XAArchiveStore *store);
+gint xa_navigation_bar_history_get_length(XANavigationBar *nav_bar);
G_END_DECLS
-#endif /* __XARCHIVER_EXTRACT_ARCHIVE_DIALOG_H__ */
+#endif /* __XARCHIVER_NAVIGATION_BAR_H__*/
Deleted: xarchiver/branches/xarchiver-psybsd/src/path_bar.c
Deleted: xarchiver/branches/xarchiver-psybsd/src/path_bar.h
Copied: xarchiver/branches/xarchiver-psybsd/src/tool_bar.c (from rev 23333, xarchiver/branches/xarchiver-psybsd/src/path_bar.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/tool_bar.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/tool_bar.c 2006-10-10 13:32:20 UTC (rev 23337)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ * 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 2 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxarchiver/libxarchiver.h>
+#include "archive_store.h"
+#include "navigation_bar.h"
+#include "tool_bar.h"
+
+
+static void
+xa_tool_bar_class_init(XAToolBarClass *archive_class);
+
+static void
+xa_tool_bar_init(XAToolBar *archive);
+
+static void
+cb_xa_tool_bar_pwd_changed(XAArchiveStore *store, XAToolBar *bar);
+
+GType
+xa_tool_bar_get_type ()
+{
+ static GType xa_tool_bar_type = 0;
+
+ if (!xa_tool_bar_type)
+ {
+ static const GTypeInfo xa_tool_bar_info =
+ {
+ sizeof (XAToolBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) xa_tool_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (XAToolBar),
+ 0,
+ (GInstanceInitFunc) xa_tool_bar_init,
+ NULL
+ };
+
+ xa_tool_bar_type = g_type_register_static (XA_TYPE_NAVIGATION_BAR, "XAToolBar", &xa_tool_bar_info, 0);
+ }
+ return xa_tool_bar_type;
+}
+
+static void
+xa_tool_bar_class_init(XAToolBarClass *tool_bar_class)
+{
+}
+
+static void
+xa_tool_bar_init(XAToolBar *tool_bar)
+{
+ GtkToolItem *button = NULL;
+ XA_NAVIGATION_BAR(tool_bar)->_cb_pwd_changed = (GCallback)cb_xa_tool_bar_pwd_changed;
+ gtk_toolbar_set_style(GTK_TOOLBAR(tool_bar), GTK_TOOLBAR_ICONS);
+
+ tool_bar->back_button = gtk_tool_button_new_from_stock("gtk-go-back");
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), tool_bar->back_button, 0);
+
+ tool_bar->forward_button = gtk_tool_button_new_from_stock("gtk-go-forward");
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), tool_bar->forward_button, 1);
+
+ tool_bar->up_button = gtk_tool_button_new_from_stock("gtk-go-up");
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), tool_bar->up_button, 2);
+
+ button = gtk_tool_button_new_from_stock("gtk-home");
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), button, 3);
+
+ button = gtk_separator_tool_item_new();
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), button, 4);
+
+ button = gtk_tool_item_new();
+ tool_bar->path_field = gtk_entry_new();
+
+ gtk_container_add(GTK_CONTAINER(button), tool_bar->path_field);
+ gtk_tool_item_set_visible_horizontal(button, TRUE);
+ gtk_tool_item_set_homogeneous(button, TRUE);
+
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar), button, 5);
+ gtk_widget_show_all(GTK_WIDGET(button));
+ gtk_widget_show(GTK_WIDGET(tool_bar->path_field));
+
+}
+
+XANavigationBar *
+xa_tool_bar_new(XAArchiveStore *store)
+{
+ XANavigationBar *bar;
+
+ bar = g_object_new(XA_TYPE_TOOL_BAR, NULL);
+
+ if(store)
+ xa_navigation_bar_set_store(XA_NAVIGATION_BAR(bar), store);
+
+ return bar;
+}
+
+static void
+cb_xa_tool_bar_pwd_changed(XAArchiveStore *store, XAToolBar *tool_bar)
+{
+ gchar *path= xa_archive_store_get_pwd(store);
+ xa_navigation_bar_history_push(XA_NAVIGATION_BAR(tool_bar), path);
+ g_free(path);
+
+ GSList *path_list = xa_archive_store_get_pwd_list(store);
+ if(g_slist_length(path_list) == 1)
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
+ else
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 1);
+ if(xa_navigation_bar_history_get_length(XA_NAVIGATION_BAR(tool_bar)) <= 1)
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
+ }
+ else
+ {
+
+ }
+}
+
Copied: xarchiver/branches/xarchiver-psybsd/src/tool_bar.h (from rev 23333, xarchiver/branches/xarchiver-psybsd/src/path_bar.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/tool_bar.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/tool_bar.h 2006-10-10 13:32:20 UTC (rev 23337)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ * 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 2 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XARCHIVER_TOOL_BAR_H__
+#define __XARCHIVER_TOOL_BAR_H__
+G_BEGIN_DECLS
+
+#define XA_TYPE_TOOL_BAR xa_tool_bar_get_type()
+
+#define XA_TOOL_BAR(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ XA_TYPE_TOOL_BAR, \
+ XAToolBar))
+
+#define XA_IS_TOOL_BAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ XA_TYPE_TOOL_BAR))
+
+#define XA_TOOL_BAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ XA_TYPE_TOOL_BAR, \
+ XAToolBarClass))
+
+#define XA_IS_TOOL_BAR_CLASS(class) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ XA_TYPE_TOOL_BAR()))
+
+typedef struct _XAToolBar XAToolBar;
+
+struct _XAToolBar
+{
+ XANavigationBar parent;
+ GtkToolItem *back_button;
+ GtkToolItem *forward_button;
+ GtkToolItem *up_button;
+ GtkWidget *path_field;
+};
+
+typedef struct _XAToolBarClass XAToolBarClass;
+
+struct _XAToolBarClass
+{
+ XANavigationBarClass parent_class;
+};
+
+GType xa_tool_bar_get_type();
+XANavigationBar *xa_tool_bar_new();
+
+G_END_DECLS
+#endif /* __XARCHIVER_TOOL_BAR_H__*/
More information about the Xfce4-commits
mailing list