[easytag] Move Entry_Changed_Disable_Object to browser.c
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Move Entry_Changed_Disable_Object to browser.c
- Date: Sat, 4 May 2013 12:13:53 +0000 (UTC)
commit 93c521c185c93c2f84f635f29c6e3e97e608f798
Author: David King <amigadave amigadave com>
Date: Sat May 4 13:07:45 2013 +0100
Move Entry_Changed_Disable_Object to browser.c
Make Entry_Changed_Disable_Object static and rename it to
empty_entry_disable_widget to better reflect its purpose.
src/browser.c | 37 +++++++++++++++++++++++++++++++++----
src/misc.c | 20 --------------------
src/misc.h | 1 -
3 files changed, 33 insertions(+), 25 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index dcad9bc..a8e6e05 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -197,6 +197,8 @@ static void Run_Program_With_Selected_Files (GtkWidget *combobox);
static gboolean Run_Program (const gchar *program_name, GList *args_list);
+static void empty_entry_disable_widget (GtkWidget *widget, GtkEntry *entry);
+
static void et_rename_directory_on_response (GtkDialog *dialog,
gint response_id,
gpointer user_data);
@@ -3685,8 +3687,10 @@ void Browser_Open_Rename_Directory_Window (void)
/* Button to save: to rename directory */
Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RenameDirectoryWindow),
GTK_RESPONSE_APPLY);
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryCombo)))),"changed",
- G_CALLBACK(Entry_Changed_Disable_Object),G_OBJECT(Button));
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RenameDirectoryCombo)),
+ "changed",
+ G_CALLBACK (empty_entry_disable_widget),
+ G_OBJECT (Button));
gtk_widget_show_all(RenameDirectoryWindow);
@@ -4053,7 +4057,10 @@ void Browser_Open_Run_Program_Tree_Window (void)
Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramTreeWindow),
GTK_RESPONSE_OK);
g_signal_connect_swapped(G_OBJECT(Button),"clicked",
G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",
G_CALLBACK(Entry_Changed_Disable_Object),G_OBJECT(Button));
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ "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(RunProgramTreeWindow);
@@ -4171,7 +4178,10 @@ void Browser_Open_Run_Program_List_Window (void)
Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramListWindow),
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(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",
G_CALLBACK(Entry_Changed_Disable_Object),G_OBJECT(Button));
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ "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);
@@ -4408,6 +4418,25 @@ Run_Program (const gchar *program_name, GList *args_list)
}
/*
+ * empty_entry_disable_widget:
+ * @widget: a widget to set sensitive if @entry contains text
+ * @entry: the entry for which to test the text
+ *
+ * Make @widget insensitive if @entry contains no text, or sensitive otherwise.
+ */
+static void
+empty_entry_disable_widget (GtkWidget *widget, GtkEntry *entry)
+{
+ const gchar *text;
+
+ g_return_if_fail (widget != NULL && entry != NULL);
+
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ gtk_widget_set_sensitive (widget, text && *text);
+}
+
+/*
* et_rename_directory_on_response:
* @dialog: the dialog which emitted the response signal
* @response_id: the response ID
diff --git a/src/misc.c b/src/misc.c
index 8c8a450..4414352 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -390,26 +390,6 @@ gchar *Get_Active_Combo_Box_Item (GtkComboBox *combo)
}
/*
- * Event attached to an entry to disable another widget (for example: a button)
- * when the entry is empty
- */
-void
-Entry_Changed_Disable_Object (GtkWidget *widget_to_disable,
- GtkEditable *source_widget)
-{
- const gchar *text;
-
- g_return_if_fail (widget_to_disable != NULL || source_widget != NULL);
-
- text = gtk_entry_get_text (GTK_ENTRY (source_widget));
-
- if (!text || strlen(text)<1)
- gtk_widget_set_sensitive(widget_to_disable,FALSE);
- else
- gtk_widget_set_sensitive(widget_to_disable,TRUE);
-}
-
-/*
* To insert only digits in an entry. If the text contains only digits: returns it,
* else only first digits.
*/
diff --git a/src/misc.h b/src/misc.h
index 4a9f086..b3f37a9 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -67,7 +67,6 @@ gchar *Get_Active_Combo_Box_Item(GtkComboBox *combo);
/*
* Other
*/
-void Entry_Changed_Disable_Object (GtkWidget *widget_to_disable, GtkEditable *source_widget);
void Insert_Only_Digit (GtkEditable *editable,const gchar *text,gint length,gint *position,gpointer data);
gboolean Parse_Date (void);
void Load_Genres_List_To_UI (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]