summaryrefslogtreecommitdiff
path: root/components/history
diff options
context:
space:
mode:
authorElliot Lee <sopwith@src.gnome.org>1999-12-09 22:50:36 +0000
committerElliot Lee <sopwith@src.gnome.org>1999-12-09 22:50:36 +0000
commit5f0d76edcd1f50d1d1837b38f3b6cb27bae10a1d (patch)
tree0613f1e521e4933c74ab6bf05c6688595767f2ae /components/history
parentb91e363766c2352d05b419b091ebb7bf6cd47acb (diff)
downloadnautilus-5f0d76edcd1f50d1d1837b38f3b6cb27bae10a1d.tar.gz
Attempt at a history view.
Attempt at a history view.
Diffstat (limited to 'components/history')
-rw-r--r--components/history/.cvsignore1
-rw-r--r--components/history/Makefile.am6
-rw-r--r--components/history/nautilus-history-view.c150
-rw-r--r--components/history/ntl-history-view.c150
-rw-r--r--components/history/ntl-history-view.goad11
5 files changed, 318 insertions, 0 deletions
diff --git a/components/history/.cvsignore b/components/history/.cvsignore
new file mode 100644
index 000000000..70845e08e
--- /dev/null
+++ b/components/history/.cvsignore
@@ -0,0 +1 @@
+Makefile.in
diff --git a/components/history/Makefile.am b/components/history/Makefile.am
new file mode 100644
index 000000000..0363f3b33
--- /dev/null
+++ b/components/history/Makefile.am
@@ -0,0 +1,6 @@
+bin_PROGRAMS=ntl-history-view
+
+INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(BONOBO_CFLAGS)
+LDADD=$(top_builddir)/libnautilus/libnautilus.la $(BONOBO_LIBS) $(GNOMEUI_LIBS)
+
+ntl_history_view_SOURCES=ntl-history-view.c
diff --git a/components/history/nautilus-history-view.c b/components/history/nautilus-history-view.c
new file mode 100644
index 000000000..130ddd46b
--- /dev/null
+++ b/components/history/nautilus-history-view.c
@@ -0,0 +1,150 @@
+#include "config.h"
+
+#include <libnautilus/libnautilus.h>
+
+typedef struct {
+ NautilusViewClient *view;
+
+ GtkCList *clist;
+
+ gint notify_count, last_row;
+} HistoryView;
+
+static void
+hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
+ Nautilus_NavigationInfo *loci,
+ HistoryView *hview)
+{
+ char *cols[2];
+ int new_rownum;
+ GtkCList *clist;
+
+ hview->notify_count++;
+
+ clist = hview->clist;
+
+ if(hview->last_row > 0)
+ {
+ char *uri;
+ int i;
+
+ /* If we are moving 'forward' in history, must either just select a new row that is farther ahead in history,
+ or delete all the history ahead of this point */
+ gtk_clist_get_text(clist, hview->last_row - 1, 1, &uri);
+ if(!strcmp(uri, loci->requested_uri))
+ {
+ new_rownum = --hview->last_row;
+ goto skip_prepend;
+ }
+
+ for(i = 0; i <= hview->last_row; i++)
+ gtk_clist_remove(clist, 0);
+ }
+
+ gtk_clist_freeze(clist);
+ cols[0] = (char *)loci->requested_uri;
+ hview->last_row = new_rownum = gtk_clist_prepend(clist, cols);
+
+ skip_prepend:
+ gtk_clist_columns_autosize(clist);
+
+ if(gtk_clist_row_is_visible(clist, new_rownum) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto(clist, new_rownum, -1, 0.5, 0.0);
+
+ gtk_clist_select_row(clist, new_rownum, 0);
+
+ gtk_clist_thaw(clist);
+
+ hview->notify_count--;
+}
+
+static void
+hyperbola_navigation_history_select_row(GtkCList *clist, gint row, gint column, GdkEvent *event,
+ HistoryView *hview)
+{
+ Nautilus_NavigationRequestInfo reqi;
+
+ if(hview->notify_count > 0)
+ return;
+
+ gtk_clist_freeze(clist);
+
+ if(hview->last_row == row)
+ return;
+
+ hview->last_row = row;
+
+ if(gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto(clist, row, -1, 0.5, 0.0);
+
+ gtk_clist_get_text(clist, row, 0, &reqi.requested_uri);
+
+ reqi.new_window_default = reqi.new_window_suggested = Nautilus_V_FALSE;
+ reqi.new_window_enforced = Nautilus_V_FALSE;
+
+ nautilus_view_client_request_location_change(hview->view, &reqi);
+
+ gtk_clist_thaw(clist);
+}
+
+
+static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id, void *closure)
+{
+ GtkWidget *client, *clist, *wtmp;
+ GnomeObject *ctl;
+ GnomePropertyBag *bag;
+ char *col_titles[1];
+ HistoryView *hview;
+
+ g_return_val_if_fail(!strcmp(goad_id, "ntl_history_view"), NULL);
+
+ hview = g_new0(HistoryView, 1);
+ client = gtk_widget_new(nautilus_meta_view_client_get_type(), NULL);
+
+ ctl = nautilus_view_client_get_gnome_object(NAUTILUS_VIEW_CLIENT(client));
+
+ /* create interface */
+ col_titles[0] = _("Path");
+ clist = gtk_clist_new_with_titles(2, col_titles);
+ gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE);
+ gtk_clist_columns_autosize(GTK_CLIST(clist));
+ wtmp = gtk_scrolled_window_new(gtk_clist_get_hadjustment(GTK_CLIST(clist)),
+ gtk_clist_get_vadjustment(GTK_CLIST(clist)));
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(wtmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(client), wtmp);
+ gtk_container_add(GTK_CONTAINER(wtmp), clist);
+
+ gtk_widget_show_all(client);
+
+ /* handle events */
+ gtk_signal_connect(GTK_OBJECT(client), "notify_location_change", hyperbola_navigation_history_notify_location_change, clist);
+ gtk_signal_connect(GTK_OBJECT(clist), "select_row", hyperbola_navigation_history_select_row, client);
+
+ /* set description */
+ bag = gnome_control_get_property_bag(GNOME_CONTROL(ctl));
+ gnome_property_bag_add(bag, "description", "string", _("History"), _("History"), _("Description"),
+ GNOME_PROPERTY_READ_ONLY);
+
+ hview->view = (NautilusViewClient *)client;
+ hview->clist = (GtkCList *)clist;
+
+ return ctl;
+}
+
+int main(int argc, char *argv[])
+{
+ GnomeGenericFactory *factory;
+ CORBA_ORB orb;
+ CORBA_Environment ev;
+
+ CORBA_exception_init(&ev);
+ orb = gnome_CORBA_init_with_popt_table("ntl-history-view", VERSION, &argc, argv, NULL, 0, NULL,
+ GNORBA_INIT_SERVER_FUNC, &ev);
+ bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
+
+ factory = gnome_generic_factory_new("ntl_history_view_factory", make_obj, NULL);
+
+ gtk_main();
+
+ return 0;
+}
diff --git a/components/history/ntl-history-view.c b/components/history/ntl-history-view.c
new file mode 100644
index 000000000..130ddd46b
--- /dev/null
+++ b/components/history/ntl-history-view.c
@@ -0,0 +1,150 @@
+#include "config.h"
+
+#include <libnautilus/libnautilus.h>
+
+typedef struct {
+ NautilusViewClient *view;
+
+ GtkCList *clist;
+
+ gint notify_count, last_row;
+} HistoryView;
+
+static void
+hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
+ Nautilus_NavigationInfo *loci,
+ HistoryView *hview)
+{
+ char *cols[2];
+ int new_rownum;
+ GtkCList *clist;
+
+ hview->notify_count++;
+
+ clist = hview->clist;
+
+ if(hview->last_row > 0)
+ {
+ char *uri;
+ int i;
+
+ /* If we are moving 'forward' in history, must either just select a new row that is farther ahead in history,
+ or delete all the history ahead of this point */
+ gtk_clist_get_text(clist, hview->last_row - 1, 1, &uri);
+ if(!strcmp(uri, loci->requested_uri))
+ {
+ new_rownum = --hview->last_row;
+ goto skip_prepend;
+ }
+
+ for(i = 0; i <= hview->last_row; i++)
+ gtk_clist_remove(clist, 0);
+ }
+
+ gtk_clist_freeze(clist);
+ cols[0] = (char *)loci->requested_uri;
+ hview->last_row = new_rownum = gtk_clist_prepend(clist, cols);
+
+ skip_prepend:
+ gtk_clist_columns_autosize(clist);
+
+ if(gtk_clist_row_is_visible(clist, new_rownum) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto(clist, new_rownum, -1, 0.5, 0.0);
+
+ gtk_clist_select_row(clist, new_rownum, 0);
+
+ gtk_clist_thaw(clist);
+
+ hview->notify_count--;
+}
+
+static void
+hyperbola_navigation_history_select_row(GtkCList *clist, gint row, gint column, GdkEvent *event,
+ HistoryView *hview)
+{
+ Nautilus_NavigationRequestInfo reqi;
+
+ if(hview->notify_count > 0)
+ return;
+
+ gtk_clist_freeze(clist);
+
+ if(hview->last_row == row)
+ return;
+
+ hview->last_row = row;
+
+ if(gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto(clist, row, -1, 0.5, 0.0);
+
+ gtk_clist_get_text(clist, row, 0, &reqi.requested_uri);
+
+ reqi.new_window_default = reqi.new_window_suggested = Nautilus_V_FALSE;
+ reqi.new_window_enforced = Nautilus_V_FALSE;
+
+ nautilus_view_client_request_location_change(hview->view, &reqi);
+
+ gtk_clist_thaw(clist);
+}
+
+
+static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id, void *closure)
+{
+ GtkWidget *client, *clist, *wtmp;
+ GnomeObject *ctl;
+ GnomePropertyBag *bag;
+ char *col_titles[1];
+ HistoryView *hview;
+
+ g_return_val_if_fail(!strcmp(goad_id, "ntl_history_view"), NULL);
+
+ hview = g_new0(HistoryView, 1);
+ client = gtk_widget_new(nautilus_meta_view_client_get_type(), NULL);
+
+ ctl = nautilus_view_client_get_gnome_object(NAUTILUS_VIEW_CLIENT(client));
+
+ /* create interface */
+ col_titles[0] = _("Path");
+ clist = gtk_clist_new_with_titles(2, col_titles);
+ gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE);
+ gtk_clist_columns_autosize(GTK_CLIST(clist));
+ wtmp = gtk_scrolled_window_new(gtk_clist_get_hadjustment(GTK_CLIST(clist)),
+ gtk_clist_get_vadjustment(GTK_CLIST(clist)));
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(wtmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(client), wtmp);
+ gtk_container_add(GTK_CONTAINER(wtmp), clist);
+
+ gtk_widget_show_all(client);
+
+ /* handle events */
+ gtk_signal_connect(GTK_OBJECT(client), "notify_location_change", hyperbola_navigation_history_notify_location_change, clist);
+ gtk_signal_connect(GTK_OBJECT(clist), "select_row", hyperbola_navigation_history_select_row, client);
+
+ /* set description */
+ bag = gnome_control_get_property_bag(GNOME_CONTROL(ctl));
+ gnome_property_bag_add(bag, "description", "string", _("History"), _("History"), _("Description"),
+ GNOME_PROPERTY_READ_ONLY);
+
+ hview->view = (NautilusViewClient *)client;
+ hview->clist = (GtkCList *)clist;
+
+ return ctl;
+}
+
+int main(int argc, char *argv[])
+{
+ GnomeGenericFactory *factory;
+ CORBA_ORB orb;
+ CORBA_Environment ev;
+
+ CORBA_exception_init(&ev);
+ orb = gnome_CORBA_init_with_popt_table("ntl-history-view", VERSION, &argc, argv, NULL, 0, NULL,
+ GNORBA_INIT_SERVER_FUNC, &ev);
+ bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
+
+ factory = gnome_generic_factory_new("ntl_history_view_factory", make_obj, NULL);
+
+ gtk_main();
+
+ return 0;
+}
diff --git a/components/history/ntl-history-view.goad b/components/history/ntl-history-view.goad
new file mode 100644
index 000000000..f684c5895
--- /dev/null
+++ b/components/history/ntl-history-view.goad
@@ -0,0 +1,11 @@
+[ntl_history_view_factory]
+type=exe
+repo_id=IDL:GNOME/GenericFactory:1.0
+description=Factory for history views
+location_info=ntl-history-view
+
+[ntl_history_view]
+type=factory
+repo_id=IDL:GNOME/Control:1.0 IDL:Nautilus/MetaView:1.0 IDL:Nautilus/View:1.0
+description=History
+location_info=ntl_history_view_factory