[easytag/wip/application-window: 16/17] Move browser to EtBrowser object
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 16/17] Move browser to EtBrowser object
- Date: Fri, 14 Mar 2014 17:17:11 +0000 (UTC)
commit 1e07c92ba9f21e6434847a93955491f96976e6e7
Author: David King <amigadave amigadave com>
Date: Wed Feb 12 23:06:30 2014 +0000
Move browser to EtBrowser object
src/application_window.c | 38 +++++-
src/application_window.h | 2 +
src/bar.c | 4 +-
src/browser.c | 361 +++++++++++++++++++++++++++++-----------------
src/browser.h | 38 +++++-
5 files changed, 298 insertions(+), 145 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index bfeb8d9..d740653 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -46,6 +46,8 @@ G_DEFINE_TYPE (EtApplicationWindow, et_application_window, GTK_TYPE_WINDOW)
struct _EtApplicationWindowPrivate
{
+ GtkWidget *browser;
+
GtkWidget *file_area;
GtkWidget *log_area;
GtkWidget *tag_area;
@@ -949,16 +951,18 @@ et_tag_field_on_key_press_event (GtkEntry *entry, GdkEventKey *event,
}
static GtkWidget *
-create_browser_area (void)
+create_browser_area (EtApplicationWindow *self)
{
+ EtApplicationWindowPrivate *priv;
GtkWidget *frame;
- GtkWidget *tree;
+
+ priv = et_application_window_get_instance_private (self);
frame = gtk_frame_new (_("Browser"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
- tree = Create_Browser_Items (MainWindow);
- gtk_container_add (GTK_CONTAINER (frame), tree);
+ priv->browser = GTK_WIDGET (et_browser_new ());
+ gtk_container_add (GTK_CONTAINER (frame), priv->browser);
/* Don't load init dir here because Tag area hasn't been yet created!.
* It will be load at the end of the main function */
@@ -1718,7 +1722,7 @@ et_application_window_init (EtApplicationWindow *self)
priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
/* Browser (Tree + File list + Entry) */
- widget = create_browser_area ();
+ widget = create_browser_area (self);
gtk_paned_pack1 (GTK_PANED (priv->hpaned), widget, TRUE, TRUE);
/* Vertical box for FileArea + TagArea */
@@ -1989,6 +1993,30 @@ et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action
et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
}
+void
+et_application_window_show_open_directory_with_dialog (G_GNUC_UNUSED GtkAction *action,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_show_open_directory_with_dialog (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_open_files_with_dialog (G_GNUC_UNUSED GtkAction *action,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_show_open_files_with_dialog (ET_BROWSER (priv->browser));
+}
+
GtkWidget *
et_application_window_get_scan_dialog (EtApplicationWindow *self)
{
diff --git a/src/application_window.h b/src/application_window.h
index d4976dd..e51eba5 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -62,6 +62,8 @@ void et_application_window_show_preferences_dialog (GtkAction *action, gpointer
GtkWidget * et_application_window_get_cddb_dialog (EtApplicationWindow *self);
void et_application_window_show_cddb_dialog (GtkAction *action, gpointer user_data);
void et_application_window_search_cddb_for_selection (GtkAction *action, gpointer user_data);
+void et_application_window_show_open_directory_with_dialog (GtkAction *action, gpointer user_data);
+void et_application_window_show_open_files_with_dialog (GtkAction *action, gpointer user_data);
GtkWidget * et_application_window_get_scan_dialog (EtApplicationWindow *self);
void et_application_window_show_scan_dialog (GtkAction *action, gpointer user_data);
void et_application_window_scan_selected_files (GtkAction *action, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index 67e8246..419cdfe 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -205,7 +205,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ AM_OPEN_FILE_WITH, GTK_STOCK_OPEN, _("Open Files With…"),
"<Primary><Shift>O", _("Run a command on the selected files"),
- G_CALLBACK (Browser_Open_Run_Program_List_Window) },
+ G_CALLBACK (et_application_window_show_open_files_with_dialog) },
{ AM_SELECT_ALL, GTK_STOCK_SELECT_ALL, NULL, "<Primary>A",
_("Select all"), G_CALLBACK (et_application_window_select_all) },
{ AM_UNSELECT_ALL, "easytag-unselect-all", _("Unselect All"),
@@ -280,7 +280,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ AM_BROWSE_DIRECTORY_WITH, GTK_STOCK_EXECUTE,
_("Browse Directory With…"), NULL,
_("Run a command on the directory"),
- G_CALLBACK (Browser_Open_Run_Program_Tree_Window) },
+ G_CALLBACK (et_application_window_show_open_directory_with_dialog) },
{ AM_COLLAPSE_TREE, NULL, _("_Collapse Tree"), "<Primary><Shift>C",
_("Collapse directory tree"), G_CALLBACK (Browser_Tree_Collapse) },
{ AM_INITIALIZE_TREE, GTK_STOCK_REFRESH, _("_Reload Tree"),
diff --git a/src/browser.c b/src/browser.c
index dae41e0..ef3a215 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -24,7 +24,9 @@
* Thomas Nilsson and 4Front Technologies
*/
-#include <config.h>
+#include "config.h"
+
+#include "browser.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@@ -41,7 +43,6 @@
#include "application_window.h"
#include "gtk2_compat.h"
#include "easytag.h"
-#include "browser.h"
#include "et_core.h"
#include "scan_dialog.h"
#include "bar.h"
@@ -55,6 +56,19 @@
#include "win32/win32dep.h"
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtBrowser, et_browser, GTK_TYPE_BOX)
+
+#define et_browser_get_instance_private(browser) (browser->priv)
+
+struct _EtBrowserPrivate
+{
+ GtkWidget *open_directory_with_dialog;
+ GtkWidget *open_directory_with_combobox;
+
+ GtkWidget *open_files_with_dialog;
+ GtkWidget *open_files_with_combobox;
+};
/****************
* Declarations *
@@ -73,9 +87,6 @@ static gchar *BrowserCurrentPath = NULL;
static GtkListStore *RunProgramModel;
-static GtkWidget *RunProgramTreeWindow = NULL;
-static GtkWidget *RunProgramListWindow = NULL;
-
/* The Rename Directory window. */
GtkWidget *RenameDirectoryWindow = NULL;
static GtkWidget *RenameDirectoryCombo;
@@ -184,12 +195,11 @@ static void Rename_Directory (void);
static void Rename_Directory_With_Mask_Toggled (void);
/* For window to run a program with the directory */
-static void Destroy_Run_Program_Tree_Window (void);
-static void Run_Program_With_Directory (GtkWidget *combobox);
+static void Destroy_Run_Program_Tree_Window (EtBrowser *self);
+static void Run_Program_With_Directory (EtBrowser *self);
/* For window to run a program with the file */
-static void Destroy_Run_Program_List_Window (void);
-static void Run_Program_With_Selected_Files (GtkWidget *combobox);
+static void Destroy_Run_Program_List_Window (EtBrowser *self);
static void empty_entry_disable_widget (GtkWidget *widget, GtkEntry *entry);
@@ -3080,9 +3090,10 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
/*
* Create item of the browser (Entry + Tree + List).
*/
-GtkWidget *Create_Browser_Items (GtkWidget *parent)
+static void
+create_browser (EtBrowser *self)
{
- GtkWidget *VerticalBox;
+ GtkWidget *VerticalBox;
GtkWidget *HBox;
GtkWidget *ScrollWindowDirectoryTree;
GtkWidget *ScrollWindowFileList;
@@ -3106,9 +3117,9 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
N_("# Files") };
const gchar *AlbumList_Titles[] = { N_("Album"), N_("# Files") };
- VerticalBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
- gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
+ VerticalBox = GTK_WIDGET (self);
+ gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
// HBox for BrowserEntry + BrowserLabel
HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
@@ -3477,12 +3488,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
/* TODO: Give the browser area a sensible default size. */
gtk_paned_set_position (GTK_PANED (BrowserHPaned), 250);
- gtk_widget_show_all(VerticalBox);
+ gtk_widget_show_all (GTK_WIDGET (self));
/* Set home variable as current path */
Browser_Update_Current_Path (g_get_home_dir ());
-
- return VerticalBox;
}
/*
@@ -3977,18 +3986,23 @@ Rename_Directory_With_Mask_Toggled (void)
* Window where is typed the name of the program to run, which
* receives the current directory as parameter.
*/
-void Browser_Open_Run_Program_Tree_Window (void)
+void
+et_browser_show_open_directory_with_dialog (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkWidget *VBox;
GtkWidget *HBox;
GtkWidget *Label;
- GtkWidget *RunProgramComboBox;
GtkWidget *Button;
gchar *current_directory = NULL;
- if (RunProgramTreeWindow != NULL)
+ g_return_if_fail (ET_BROWSER (self));
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_directory_with_dialog != NULL)
{
- gtk_window_present(GTK_WINDOW(RunProgramTreeWindow));
+ gtk_window_present(GTK_WINDOW(priv->open_directory_with_dialog));
return;
}
@@ -3997,7 +4011,7 @@ void Browser_Open_Run_Program_Tree_Window (void)
if (!current_directory || strlen(current_directory)==0)
return;
- RunProgramTreeWindow = gtk_dialog_new_with_buttons (_("Browse Directory With"),
+ priv->open_directory_with_dialog = gtk_dialog_new_with_buttons (_("Browse Directory With"),
GTK_WINDOW (MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -4005,12 +4019,12 @@ void Browser_Open_Run_Program_Tree_Window (void)
GTK_STOCK_EXECUTE,
GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (RunProgramTreeWindow),
+ gtk_dialog_set_default_response (GTK_DIALOG (priv->open_directory_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect (RunProgramTreeWindow, "response",
- G_CALLBACK (et_run_program_tree_on_response), NULL);
- VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramTreeWindow));
- gtk_container_set_border_width (GTK_CONTAINER (RunProgramTreeWindow),
+ g_signal_connect (priv->open_directory_with_dialog, "response",
+ G_CALLBACK (et_run_program_tree_on_response), self);
+ VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_directory_with_dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (priv->open_directory_with_dialog),
BOX_SPACING);
Label = gtk_label_new(_("Program to run:"));
@@ -4021,62 +4035,72 @@ void Browser_Open_Run_Program_Tree_Window (void)
gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,2);
/* The combobox to enter the program to run */
- RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox), MISC_COMBO_TEXT);
- gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
- gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter
the program to run. "
+ priv->open_directory_with_combobox =
gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->open_directory_with_combobox), MISC_COMBO_TEXT);
+ gtk_box_pack_start(GTK_BOX(HBox),priv->open_directory_with_combobox,TRUE,TRUE,0);
+ gtk_widget_set_size_request(GTK_WIDGET(priv->open_directory_with_combobox),250,-1);
+
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),_("Enter
the program to run. "
"It will receive the current directory as parameter."));
/* History list */
gtk_list_store_clear(RunProgramModel);
Load_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
- G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
+ g_signal_connect_swapped (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox))),
+ "activate",
+ G_CALLBACK (Run_Program_With_Directory),
+ self);
/* The button to Browse */
Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox))));
/* We attach useful data to the combobox (into Run_Program_With_Directory) */
- g_object_set_data(G_OBJECT(RunProgramComboBox), "Current_Directory", current_directory);
+ g_object_set_data(G_OBJECT(priv->open_directory_with_combobox), "Current_Directory", current_directory);
/* Button to execute */
- Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramTreeWindow),
+ Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_directory_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect_swapped(G_OBJECT(Button),"clicked",
G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
- g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ g_signal_connect_swapped (Button, "clicked",
+ G_CALLBACK (Run_Program_With_Directory),
+ self);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox)),
"changed",
G_CALLBACK (empty_entry_disable_widget),
G_OBJECT (Button));
-
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
+
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),"changed",NULL);
- gtk_widget_show_all(RunProgramTreeWindow);
+ gtk_widget_show_all(priv->open_directory_with_dialog);
}
static void
-Destroy_Run_Program_Tree_Window (void)
+Destroy_Run_Program_Tree_Window (EtBrowser *self)
{
- if (RunProgramTreeWindow)
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_directory_with_dialog)
{
- gtk_widget_destroy(RunProgramTreeWindow);
- RunProgramTreeWindow = NULL;
+ gtk_widget_hide (priv->open_directory_with_dialog);
}
}
-void Run_Program_With_Directory (GtkWidget *combobox)
+void
+Run_Program_With_Directory (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
gchar *program_name;
gchar *current_directory;
GList *args_list = NULL;
gboolean program_ran;
- g_return_if_fail (GTK_IS_COMBO_BOX (combobox));
+ priv = et_browser_get_instance_private (self);
- program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
- current_directory = g_object_get_data(G_OBJECT(combobox), "Current_Directory");
+ program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN
(priv->open_directory_with_combobox)))));
+ current_directory = g_object_get_data (G_OBJECT (priv->open_directory_with_combobox),
+ "Current_Directory");
#ifdef G_OS_WIN32
/* On win32 : 'winamp.exe "c:\path\to\dir"' succeed, while 'winamp.exe "c:\path\to\dir\"' fails */
ET_Win32_Path_Remove_Trailing_Backslash(current_directory);
@@ -4096,7 +4120,66 @@ void Run_Program_With_Directory (GtkWidget *combobox)
// Save list attached to the combobox
Save_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
- Destroy_Run_Program_Tree_Window();
+ Destroy_Run_Program_Tree_Window (self);
+ }
+ g_free(program_name);
+}
+
+static void
+Run_Program_With_Selected_Files (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+ gchar *program_name;
+ ET_File *ETFile;
+ GList *selected_paths;
+ GList *l;
+ GList *args_list = NULL;
+ GtkTreeIter iter;
+ gboolean program_ran;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (!GTK_IS_COMBO_BOX (priv->open_files_with_combobox) || !ETCore->ETFileDisplayedList)
+ return;
+
+ // Programe name to run
+ program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN
(priv->open_files_with_combobox)))));
+
+ // List of files to pass as parameters
+ selected_paths =
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
+
+ for (l = selected_paths; l != NULL; l = g_list_next (l))
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
+ (GtkTreePath *)l->data))
+ {
+ gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
+ LIST_FILE_POINTER, &ETFile,
+ -1);
+
+ args_list = g_list_prepend (args_list,
+ ((File_Name *)ETFile->FileNameCur->data)->value);
+ //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
+ }
+ }
+
+ args_list = g_list_reverse (args_list);
+ program_ran = et_run_program (program_name, args_list);
+
+ g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
+ g_list_free(args_list);
+
+ if (program_ran)
+ {
+ // Append newest choice to the drop down list
+ //gtk_list_store_prepend(GTK_LIST_STORE(RunProgramModel), &iter);
+ //gtk_list_store_set(RunProgramModel, &iter, MISC_COMBO_TEXT, program_name, -1);
+ Add_String_To_Combo_List(GTK_LIST_STORE(RunProgramModel), program_name);
+
+ // Save list attached to the combobox
+ Save_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
+
+ Destroy_Run_Program_List_Window (self);
}
g_free(program_name);
}
@@ -4105,21 +4188,26 @@ void Run_Program_With_Directory (GtkWidget *combobox)
* Window where is typed the name of the program to run, which
* receives the current file as parameter.
*/
-void Browser_Open_Run_Program_List_Window (void)
+void
+et_browser_show_open_files_with_dialog (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkWidget *VBox;
GtkWidget *HBox;
GtkWidget *Label;
- GtkWidget *RunProgramComboBox;
GtkWidget *Button;
- if (RunProgramListWindow != NULL)
+ g_return_if_fail (ET_BROWSER (self));
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_files_with_dialog != NULL)
{
- gtk_window_present(GTK_WINDOW(RunProgramListWindow));
+ gtk_window_present(GTK_WINDOW(priv->open_files_with_dialog));
return;
}
- RunProgramListWindow = gtk_dialog_new_with_buttons (_("Open Files With"),
+ priv->open_files_with_dialog = gtk_dialog_new_with_buttons (_("Open Files With"),
GTK_WINDOW (MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -4128,15 +4216,15 @@ void Browser_Open_Run_Program_List_Window (void)
GTK_RESPONSE_OK,
NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (RunProgramListWindow),
+ gtk_dialog_set_default_response (GTK_DIALOG (priv->open_files_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect ((RunProgramListWindow), "response",
- G_CALLBACK (et_run_program_list_on_response), NULL);
+ g_signal_connect ((priv->open_files_with_dialog), "response",
+ G_CALLBACK (et_run_program_list_on_response), self);
- gtk_container_set_border_width (GTK_CONTAINER (RunProgramListWindow),
+ gtk_container_set_border_width (GTK_CONTAINER (priv->open_files_with_dialog),
BOX_SPACING);
- VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramListWindow));
+ VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_files_with_dialog));
gtk_container_set_border_width (GTK_CONTAINER(VBox), BOX_SPACING);
Label = gtk_label_new(_("Program to run:"));
@@ -4147,102 +4235,57 @@ void Browser_Open_Run_Program_List_Window (void)
gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,0);
/* The combobox to enter the program to run */
- RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox),MISC_COMBO_TEXT);
- gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
- gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter
the program to run. "
- "It will receive the current file as parameter."));
+ priv->open_files_with_combobox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->open_files_with_combobox),
+ MISC_COMBO_TEXT);
+ gtk_box_pack_start (GTK_BOX (HBox), priv->open_files_with_combobox, TRUE,
+ TRUE, 0);
+ gtk_widget_set_size_request (GTK_WIDGET (priv->open_files_with_combobox),
+ 250, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox))),
+ _("Enter the program to run. It will receive the current file as
parameter."));
/* History list */
gtk_list_store_clear(RunProgramModel);
Load_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
- G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+ "activate",
+ G_CALLBACK (Run_Program_With_Selected_Files),
+ self);
/* The button to Browse */
Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_files_with_combobox))));
/* Button to execute */
- Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramListWindow),
+ Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_files_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect_swapped(G_OBJECT(Button),"clicked",
G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
- g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ g_signal_connect_swapped (Button, "clicked",
+ G_CALLBACK (Run_Program_With_Selected_Files),
+ self);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
"changed",
G_CALLBACK (empty_entry_disable_widget),
G_OBJECT (Button));
-
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
-
- gtk_widget_show_all(RunProgramListWindow);
-}
+ g_signal_emit_by_name (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+ "changed", NULL);
-static void
-Destroy_Run_Program_List_Window (void)
-{
- if (RunProgramListWindow)
- {
- gtk_widget_destroy(RunProgramListWindow);
- RunProgramListWindow = NULL;
- }
+ gtk_widget_show_all(priv->open_files_with_dialog);
}
static void
-Run_Program_With_Selected_Files (GtkWidget *combobox)
+Destroy_Run_Program_List_Window (EtBrowser *self)
{
- gchar *program_name;
- ET_File *ETFile;
- GList *selected_paths;
- GList *l;
- GList *args_list = NULL;
- GtkTreeIter iter;
- gboolean program_ran;
-
- if (!GTK_IS_COMBO_BOX(combobox) || !ETCore->ETFileDisplayedList)
- return;
-
- // Programe name to run
- program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
-
- // List of files to pass as parameters
- selected_paths =
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
+ EtBrowserPrivate *priv;
- for (l = selected_paths; l != NULL; l = g_list_next (l))
- {
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
- (GtkTreePath *)l->data))
- {
- gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
- LIST_FILE_POINTER, &ETFile,
- -1);
-
- args_list = g_list_prepend (args_list,
- ((File_Name *)ETFile->FileNameCur->data)->value);
- //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
- }
- }
-
- args_list = g_list_reverse (args_list);
- program_ran = et_run_program (program_name, args_list);
-
- g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
- g_list_free(args_list);
+ priv = et_browser_get_instance_private (self);
- if (program_ran)
+ if (priv->open_files_with_dialog)
{
- // Append newest choice to the drop down list
- //gtk_list_store_prepend(GTK_LIST_STORE(RunProgramModel), &iter);
- //gtk_list_store_set(RunProgramModel, &iter, MISC_COMBO_TEXT, program_name, -1);
- Add_String_To_Combo_List(GTK_LIST_STORE(RunProgramModel), program_name);
-
- // Save list attached to the combobox
- Save_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
-
- Destroy_Run_Program_List_Window();
+ gtk_widget_hide (priv->open_files_with_dialog);
}
- g_free(program_name);
}
/*
@@ -4302,6 +4345,10 @@ static void
et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
gpointer user_data)
{
+ EtBrowser *self;
+
+ self = ET_BROWSER (user_data);
+
switch (response_id)
{
case GTK_RESPONSE_OK:
@@ -4309,7 +4356,7 @@ et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
- Destroy_Run_Program_Tree_Window ();
+ Destroy_Run_Program_Tree_Window (self);
break;
default:
g_assert_not_reached ();
@@ -4327,6 +4374,10 @@ static void
et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
gpointer user_data)
{
+ EtBrowser *self;
+
+ self = ET_BROWSER (user_data);
+
switch (response_id)
{
case GTK_RESPONSE_OK:
@@ -4334,7 +4385,7 @@ et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
- Destroy_Run_Program_List_Window ();
+ Destroy_Run_Program_List_Window (self);
break;
default:
g_assert_not_reached ();
@@ -4369,3 +4420,47 @@ get_column_for_column_id (gint column_id)
{
return gtk_tree_view_get_column (GTK_TREE_VIEW (BrowserList), column_id);
}
+
+static void
+et_browser_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (et_browser_parent_class)->finalize (object);
+}
+
+static void
+et_browser_init (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+
+ priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_BROWSER,
+ EtBrowserPrivate);
+
+ priv->open_directory_with_dialog = NULL;
+ priv->open_directory_with_combobox = NULL;
+ priv->open_files_with_dialog = NULL;
+ priv->open_files_with_combobox = NULL;
+
+ create_browser (self);
+}
+
+static void
+et_browser_class_init (EtBrowserClass *klass)
+{
+ G_OBJECT_CLASS (klass)->finalize = et_browser_finalize;
+
+ g_type_class_add_private (klass, sizeof (EtBrowserPrivate));
+}
+
+/*
+ * et_browser_new:
+ *
+ * Create a new EtBrowser instance.
+ *
+ * Returns: a new #EtBrowser
+ */
+EtBrowser *
+et_browser_new (void)
+{
+ return g_object_new (ET_TYPE_BROWSER, "orientation",
+ GTK_ORIENTATION_VERTICAL, NULL);
+}
diff --git a/src/browser.h b/src/browser.h
index 5965379..3093804 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -1,4 +1,3 @@
-/* browser.h - 2000/04/28 */
/*
* EasyTAG - Tag editor for MP3 and Ogg Vorbis files
* Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
@@ -19,11 +18,41 @@
*/
-#ifndef __BROWSER_H__
-#define __BROWSER_H__
+#ifndef ET_BROWSER_H_
+#define ET_BROWSER_H_
#include "et_core.h"
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_BROWSER (et_browser_get_type ())
+#define ET_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_BROWSER, EtBrowser))
+
+typedef struct _EtBrowser EtBrowser;
+typedef struct _EtBrowserClass EtBrowserClass;
+typedef struct _EtBrowserPrivate EtBrowserPrivate;
+
+struct _EtBrowser
+{
+ /*< private >*/
+ GtkBox parent_instance;
+ EtBrowserPrivate *priv;
+};
+
+struct _EtBrowserClass
+{
+ /*< private >*/
+ GtkBoxClass parent_class;
+};
+
+GType et_browser_get_type (void);
+EtBrowser *et_browser_new (void);
+void et_browser_show_open_directory_with_dialog (EtBrowser *self);
+void et_browser_show_open_files_with_dialog (EtBrowser *self);
+
+G_END_DECLS
/****************
* Declarations *
@@ -142,7 +171,6 @@ GtkWidget *RenameDirectoryPreviewLabel;
* Prototypes *
**************/
-GtkWidget *Create_Browser_Items (GtkWidget *parent);
gboolean Browser_Tree_Select_Dir (const gchar *current_path);
void Browser_Tree_Rebuild (gchar *path_to_load);
void Browser_Tree_Collapse (void);
@@ -189,4 +217,4 @@ void Browser_Open_Run_Program_List_Window (void);
GtkTreeViewColumn *get_column_for_column_id (gint column_id);
GtkSortType get_sort_order_for_column_id (gint column_id);
-#endif /* __BROWSER_H__ */
+#endif /* ET_BROWSER_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]