Address bar drop-down menu has parent folders (better than nothing)
This commit is contained in:
parent
03abee991c
commit
97b0fb9488
|
@ -8,6 +8,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "browser.h"
|
#include "browser.h"
|
||||||
|
|
||||||
|
@ -210,6 +211,8 @@ Browser * browser_new(char const * directory)
|
||||||
gtk_entry_set_text(GTK_ENTRY(widget), browser->current->data);
|
gtk_entry_set_text(GTK_ENTRY(widget), browser->current->data);
|
||||||
g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(
|
g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(
|
||||||
on_path_activate), browser);
|
on_path_activate), browser);
|
||||||
|
g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(
|
||||||
|
on_path_change), browser);
|
||||||
toolitem = gtk_tool_item_new();
|
toolitem = gtk_tool_item_new();
|
||||||
gtk_tool_item_set_expand(toolitem, TRUE);
|
gtk_tool_item_set_expand(toolitem, TRUE);
|
||||||
gtk_container_add(GTK_CONTAINER(toolitem), browser->tb_path);
|
gtk_container_add(GTK_CONTAINER(toolitem), browser->tb_path);
|
||||||
|
@ -340,13 +343,14 @@ static GtkListStore * _create_store(Browser * browser)
|
||||||
GtkListStore * store;
|
GtkListStore * store;
|
||||||
|
|
||||||
store = gtk_list_store_new(BR_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING,
|
store = gtk_list_store_new(BR_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING,
|
||||||
|
GDK_TYPE_PIXBUF,
|
||||||
#if !GTK_CHECK_VERSION(2, 6, 0)
|
#if !GTK_CHECK_VERSION(2, 6, 0)
|
||||||
GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_UINT64,
|
G_TYPE_BOOLEAN,
|
||||||
#else
|
#else
|
||||||
GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN,
|
GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN,
|
||||||
G_TYPE_UINT64,
|
|
||||||
#endif
|
#endif
|
||||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
G_TYPE_UINT64, G_TYPE_STRING, G_TYPE_STRING,
|
||||||
|
G_TYPE_STRING);
|
||||||
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store),
|
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store),
|
||||||
_sort_func, browser, NULL);
|
_sort_func, browser, NULL);
|
||||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
|
||||||
|
@ -388,22 +392,21 @@ int browser_error(Browser * browser, char const * message, int ret)
|
||||||
|
|
||||||
|
|
||||||
static void _refresh_title(Browser * browser);
|
static void _refresh_title(Browser * browser);
|
||||||
|
static void _refresh_path(Browser * browser);
|
||||||
static void _refresh_loop(Browser * browser, char const * name);
|
static void _refresh_loop(Browser * browser, char const * name);
|
||||||
void browser_refresh(Browser * browser)
|
void browser_refresh(Browser * browser)
|
||||||
{
|
{
|
||||||
GDir * dir;
|
GDir * dir;
|
||||||
GtkWidget * widget;
|
|
||||||
char const * name;
|
char const * name;
|
||||||
unsigned int cnt;
|
unsigned int cnt;
|
||||||
unsigned int hidden_cnt;
|
unsigned int hidden_cnt;
|
||||||
char status[36];
|
char status[36];
|
||||||
|
|
||||||
gtk_list_store_clear(browser->store);
|
|
||||||
if((dir = g_dir_open(browser->current->data, 0, NULL)) == NULL)
|
if((dir = g_dir_open(browser->current->data, 0, NULL)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
gtk_list_store_clear(browser->store);
|
||||||
_refresh_title(browser);
|
_refresh_title(browser);
|
||||||
widget = gtk_bin_get_child(GTK_BIN(browser->tb_path));
|
_refresh_path(browser);
|
||||||
gtk_entry_set_text(GTK_ENTRY(widget), browser->current->data);
|
|
||||||
for(cnt = 0, hidden_cnt = 0; (name = g_dir_read_name(dir)) != NULL;
|
for(cnt = 0, hidden_cnt = 0; (name = g_dir_read_name(dir)) != NULL;
|
||||||
cnt++)
|
cnt++)
|
||||||
{
|
{
|
||||||
|
@ -437,6 +440,26 @@ static void _refresh_title(Browser * browser)
|
||||||
gtk_window_set_title(GTK_WINDOW(browser->window), buf);
|
gtk_window_set_title(GTK_WINDOW(browser->window), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _refresh_path(Browser * browser)
|
||||||
|
{
|
||||||
|
static unsigned int cnt = 0;
|
||||||
|
GtkWidget * widget;
|
||||||
|
unsigned int i;
|
||||||
|
char * p;
|
||||||
|
|
||||||
|
widget = gtk_bin_get_child(GTK_BIN(browser->tb_path));
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(widget), browser->current->data);
|
||||||
|
for(i = 0; i < cnt; i++)
|
||||||
|
gtk_combo_box_remove_text(GTK_COMBO_BOX(browser->tb_path), 0);
|
||||||
|
p = dirname(browser->current->data);
|
||||||
|
gtk_combo_box_append_text(GTK_COMBO_BOX(browser->tb_path), p);
|
||||||
|
for(cnt = 1; strcmp(p, "/") != 0; cnt++)
|
||||||
|
{
|
||||||
|
p = dirname(p);
|
||||||
|
gtk_combo_box_append_text(GTK_COMBO_BOX(browser->tb_path), p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _refresh_loop(Browser * browser, char const * name)
|
static void _refresh_loop(Browser * browser, char const * name)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
|
@ -653,6 +653,12 @@ void on_path_activate(GtkWidget * widget, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void on_path_change(GtkWidget * widget, gpointer data)
|
||||||
|
{
|
||||||
|
on_path_activate(widget, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* view */
|
/* view */
|
||||||
/* types */
|
/* types */
|
||||||
/* FIXME rather ugly, maybe could go directly in Browser */
|
/* FIXME rather ugly, maybe could go directly in Browser */
|
||||||
|
@ -705,6 +711,14 @@ void on_icon_default(GtkIconView * view,
|
||||||
void on_filename_edited(GtkCellRendererText * renderer, gchar * arg1,
|
void on_filename_edited(GtkCellRendererText * renderer, gchar * arg1,
|
||||||
gchar * arg2, gpointer data)
|
gchar * arg2, gpointer data)
|
||||||
{
|
{
|
||||||
|
Browser * browser = data;
|
||||||
|
gint n;
|
||||||
|
char * p;
|
||||||
|
|
||||||
|
n = strtol(arg1, &p, 10);
|
||||||
|
if(*arg1 == '\0' || *p != '\0')
|
||||||
|
/* FIXME warn user */
|
||||||
|
return;
|
||||||
/* FIXME implement */
|
/* FIXME implement */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ void on_view_as(GtkWidget * widget, gpointer data);
|
||||||
|
|
||||||
/* address bar */
|
/* address bar */
|
||||||
void on_path_activate(GtkWidget * widget, gpointer data);
|
void on_path_activate(GtkWidget * widget, gpointer data);
|
||||||
|
void on_path_change(GtkWidget * widget, gpointer data);
|
||||||
|
|
||||||
/* view */
|
/* view */
|
||||||
void on_detail_default(GtkTreeView * view,
|
void on_detail_default(GtkTreeView * view,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user