Added Current Document Directory button
parent
b3b1f5dfdb
commit
356041d3ea
|
@ -28,6 +28,7 @@
|
||||||
struct _MooEditWindowPrivate {
|
struct _MooEditWindowPrivate {
|
||||||
MooPaned *paned;
|
MooPaned *paned;
|
||||||
GtkNotebook *notebook;
|
GtkNotebook *notebook;
|
||||||
|
MooFileView *fileview;
|
||||||
gboolean use_fullname;
|
gboolean use_fullname;
|
||||||
char *app_name;
|
char *app_name;
|
||||||
MooEditor *editor;
|
MooEditor *editor;
|
||||||
|
@ -90,7 +91,7 @@ static void file_saved (MooEditWindow *window,
|
||||||
|
|
||||||
static void fileview_activate (MooEditWindow *window,
|
static void fileview_activate (MooEditWindow *window,
|
||||||
MooFileViewFile *file);
|
MooFileViewFile *file);
|
||||||
|
static void current_doc_dir_clicked (MooEditWindow *window);
|
||||||
|
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
|
@ -423,7 +424,7 @@ GObject *moo_edit_window_constructor (GType type,
|
||||||
guint n_props,
|
guint n_props,
|
||||||
GObjectConstructParam *props)
|
GObjectConstructParam *props)
|
||||||
{
|
{
|
||||||
GtkWidget *notebook, *paned, *fileview;
|
GtkWidget *notebook, *paned, *fileview, *button, *icon;
|
||||||
MooEdit *edit;
|
MooEdit *edit;
|
||||||
MooEditFileMgr *mgr = NULL;
|
MooEditFileMgr *mgr = NULL;
|
||||||
MooEditWindow *window;
|
MooEditWindow *window;
|
||||||
|
@ -450,10 +451,29 @@ GObject *moo_edit_window_constructor (GType type,
|
||||||
mgr = moo_editor_get_file_mgr (window->priv->editor);
|
mgr = moo_editor_get_file_mgr (window->priv->editor);
|
||||||
|
|
||||||
fileview = GTK_WIDGET (g_object_new (MOO_TYPE_FILE_VIEW,
|
fileview = GTK_WIDGET (g_object_new (MOO_TYPE_FILE_VIEW,
|
||||||
"file-mgr", mgr, NULL));
|
"file-mgr", mgr,
|
||||||
|
"current-directory", g_get_home_dir (),
|
||||||
|
NULL));
|
||||||
g_signal_connect_swapped (fileview, "activate",
|
g_signal_connect_swapped (fileview, "activate",
|
||||||
G_CALLBACK (fileview_activate),
|
G_CALLBACK (fileview_activate),
|
||||||
window);
|
window);
|
||||||
|
window->priv->fileview = MOO_FILE_VIEW (fileview);
|
||||||
|
|
||||||
|
icon = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_widget_show (GTK_WIDGET (icon));
|
||||||
|
button = gtk_button_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (button), icon);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
|
||||||
|
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||||
|
gtk_tooltips_set_tip (MOO_WINDOW(window)->tooltips, button,
|
||||||
|
"Current Document Directory",
|
||||||
|
"Current Document Directory");
|
||||||
|
gtk_box_pack_end (GTK_BOX (MOO_FILE_VIEW (fileview)->toolbar),
|
||||||
|
button, FALSE, FALSE, 0);
|
||||||
|
g_signal_connect_swapped (button, "clicked",
|
||||||
|
G_CALLBACK (current_doc_dir_clicked),
|
||||||
|
window);
|
||||||
|
|
||||||
moo_paned_add_pane (MOO_PANED (paned),
|
moo_paned_add_pane (MOO_PANED (paned),
|
||||||
fileview, "File Selector",
|
fileview, "File Selector",
|
||||||
|
@ -1170,3 +1190,17 @@ static void fileview_activate (MooEditWindow *window,
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (edit));
|
gtk_widget_grab_focus (GTK_WIDGET (edit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void current_doc_dir_clicked (MooEditWindow *window)
|
||||||
|
{
|
||||||
|
MooEdit *edit = moo_edit_window_get_active_doc (window);
|
||||||
|
const char *filename = moo_edit_get_filename (edit);
|
||||||
|
|
||||||
|
if (filename)
|
||||||
|
{
|
||||||
|
char *dirname = g_path_get_dirname (filename);
|
||||||
|
moo_file_view_chdir (window->priv->fileview, dirname, NULL);
|
||||||
|
g_free (dirname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ static int tree_compare_func (GtkTreeModel *model,
|
||||||
static void init_gui (MooFileView *fileview);
|
static void init_gui (MooFileView *fileview);
|
||||||
static void focus_to_file_view (MooFileView *fileview);
|
static void focus_to_file_view (MooFileView *fileview);
|
||||||
static GtkWidget *create_toolbar (MooFileView *fileview);
|
static GtkWidget *create_toolbar (MooFileView *fileview);
|
||||||
static void toolbar_button_clicked (GtkToolButton *button,
|
static void toolbar_button_clicked (GtkButton *button,
|
||||||
MooFileView *fileview);
|
MooFileView *fileview);
|
||||||
static GtkWidget *create_notebook (MooFileView *fileview);
|
static GtkWidget *create_notebook (MooFileView *fileview);
|
||||||
|
|
||||||
|
@ -466,87 +466,54 @@ static void focus_to_file_view (MooFileView *fileview)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void create_button (MooFileView *fileview,
|
||||||
|
GtkWidget *box,
|
||||||
|
GtkTooltips *tooltips,
|
||||||
|
const char *stock_id,
|
||||||
|
const char *tip,
|
||||||
|
const char *signal)
|
||||||
|
{
|
||||||
|
GtkWidget *icon, *button;
|
||||||
|
|
||||||
|
icon = gtk_image_new_from_stock (stock_id,
|
||||||
|
GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_widget_show (GTK_WIDGET (icon));
|
||||||
|
button = gtk_button_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (button), icon);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||||
|
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
|
||||||
|
gtk_tooltips_set_tip (tooltips, button, tip, tip);
|
||||||
|
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
||||||
|
g_object_set_data (G_OBJECT (button), "moo-file-view-signal",
|
||||||
|
(gpointer) signal);
|
||||||
|
g_signal_connect (button, "clicked",
|
||||||
|
G_CALLBACK (toolbar_button_clicked),
|
||||||
|
fileview);
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget *create_toolbar (MooFileView *fileview)
|
static GtkWidget *create_toolbar (MooFileView *fileview)
|
||||||
{
|
{
|
||||||
GtkWidget *toolbar, *icon;
|
GtkWidget *toolbar;
|
||||||
GtkToolItem *item;
|
|
||||||
GtkTooltips *tooltips;
|
GtkTooltips *tooltips;
|
||||||
|
|
||||||
tooltips = gtk_tooltips_new ();
|
tooltips = gtk_tooltips_new ();
|
||||||
|
toolbar = gtk_hbox_new (FALSE, 0);
|
||||||
|
|
||||||
/*********************************************************/
|
create_button (fileview, toolbar, tooltips,
|
||||||
/* Navigation toolbar */
|
GTK_STOCK_GO_UP, "Up", "go-up");
|
||||||
|
create_button (fileview, toolbar, tooltips,
|
||||||
toolbar = gtk_toolbar_new ();
|
GTK_STOCK_GO_BACK, "Back", "go-back");
|
||||||
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
|
create_button (fileview, toolbar, tooltips,
|
||||||
|
GTK_STOCK_GO_FORWARD, "Forward", "go-forward");
|
||||||
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar),
|
create_button (fileview, toolbar, tooltips,
|
||||||
GTK_ICON_SIZE_MENU);
|
GTK_STOCK_HOME, "Home", "go-home");
|
||||||
|
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
|
|
||||||
GTK_TOOLBAR_ICONS);
|
|
||||||
|
|
||||||
/* Up */
|
|
||||||
icon = gtk_image_new_from_stock (GTK_STOCK_GO_UP,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_widget_show (GTK_WIDGET (icon));
|
|
||||||
item = gtk_tool_button_new (icon, NULL);
|
|
||||||
gtk_widget_show (GTK_WIDGET (item));
|
|
||||||
gtk_tool_item_set_tooltip (item, tooltips, "Up", "Up");
|
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
|
||||||
g_object_set_data (G_OBJECT (item), "moo-file-view-signal",
|
|
||||||
(gpointer) "go-up");
|
|
||||||
g_signal_connect (item, "clicked",
|
|
||||||
G_CALLBACK (toolbar_button_clicked),
|
|
||||||
fileview);
|
|
||||||
|
|
||||||
/* Back */
|
|
||||||
icon = gtk_image_new_from_stock (GTK_STOCK_GO_BACK,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_widget_show (GTK_WIDGET (icon));
|
|
||||||
item = gtk_tool_button_new (icon, NULL);
|
|
||||||
gtk_widget_show (GTK_WIDGET (item));
|
|
||||||
gtk_tool_item_set_tooltip (item, tooltips, "Back", "Back");
|
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
|
||||||
g_object_set_data (G_OBJECT (item), "moo-file-view-signal",
|
|
||||||
(gpointer) "go-back");
|
|
||||||
g_signal_connect (item, "clicked",
|
|
||||||
G_CALLBACK (toolbar_button_clicked),
|
|
||||||
fileview);
|
|
||||||
|
|
||||||
/* Forward */
|
|
||||||
icon = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_widget_show (GTK_WIDGET (icon));
|
|
||||||
item = gtk_tool_button_new (icon, NULL);
|
|
||||||
gtk_widget_show (GTK_WIDGET (item));
|
|
||||||
gtk_tool_item_set_tooltip (item, tooltips, "Forward", "Forward");
|
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
|
||||||
g_object_set_data (G_OBJECT (item), "moo-file-view-signal",
|
|
||||||
(gpointer) "go-forward");
|
|
||||||
g_signal_connect (item, "clicked",
|
|
||||||
G_CALLBACK (toolbar_button_clicked),
|
|
||||||
fileview);
|
|
||||||
|
|
||||||
/* Home */
|
|
||||||
icon = gtk_image_new_from_stock (GTK_STOCK_HOME,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_widget_show (GTK_WIDGET (icon));
|
|
||||||
item = gtk_tool_button_new (icon, NULL);
|
|
||||||
gtk_widget_show (GTK_WIDGET (item));
|
|
||||||
gtk_tool_item_set_tooltip (item, tooltips, "Home", "Home");
|
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
|
||||||
g_object_set_data (G_OBJECT (item), "moo-file-view-signal",
|
|
||||||
(gpointer) "go-home");
|
|
||||||
g_signal_connect (item, "clicked",
|
|
||||||
G_CALLBACK (toolbar_button_clicked),
|
|
||||||
fileview);
|
|
||||||
|
|
||||||
return toolbar;
|
return toolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void toolbar_button_clicked (GtkToolButton *button,
|
static void toolbar_button_clicked (GtkButton *button,
|
||||||
MooFileView *fileview)
|
MooFileView *fileview)
|
||||||
{
|
{
|
||||||
const char *signal = g_object_get_data (G_OBJECT (button),
|
const char *signal = g_object_get_data (G_OBJECT (button),
|
||||||
|
|
Loading…
Reference in New Issue