[evolution] Remove e_dialog_editable_get().



commit 6feca1bf560b3269555d4f0a890cd192fdaa0f00
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Dec 23 17:57:26 2011 -0500

    Remove e_dialog_editable_get().
    
    Silly function.  Use gtk_entry_get_text() for a const string or else
    gtk_editable_get_chars() for an allocated string.

 calendar/gui/dialogs/alarm-dialog.c      |   32 +++++++++++-----------
 calendar/gui/dialogs/event-page.c        |   42 +++++++++++++-----------------
 calendar/gui/dialogs/memo-page.c         |   30 ++++++++-------------
 calendar/gui/dialogs/task-details-page.c |    8 ++---
 calendar/gui/dialogs/task-page.c         |   24 +++++++----------
 doc/reference/shell/eshell-sections.txt  |    1 -
 e-util/e-dialog-widgets.c                |   18 -------------
 e-util/e-dialog-widgets.h                |    2 -
 8 files changed, 59 insertions(+), 98 deletions(-)
---
diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c
index b5aaed5..d18594e 100644
--- a/calendar/gui/dialogs/alarm-dialog.c
+++ b/calendar/gui/dialogs/alarm-dialog.c
@@ -576,28 +576,24 @@ static void
 palarm_widgets_to_alarm (Dialog *dialog,
                          ECalComponentAlarm *alarm)
 {
-	gchar *program;
 	icalattach *attach;
-	gchar *str;
 	ECalComponentText description;
 	icalcomponent *icalcomp;
 	icalproperty *icalprop;
+	const gchar *text;
 
-	program = e_dialog_editable_get (dialog->palarm_program);
-	attach = icalattach_new_from_url (program ? program : "");
-	g_free (program);
+	text = gtk_entry_get_text (GTK_ENTRY (dialog->palarm_program));
+	attach = icalattach_new_from_url ((text != NULL) ? text : "");
 
 	e_cal_component_alarm_set_attach (alarm, attach);
 	icalattach_unref (attach);
 
-	str = e_dialog_editable_get (dialog->palarm_args);
-
-		description.value = str;
-		description.altrep = NULL;
+	text = gtk_entry_get_text (GTK_ENTRY (dialog->palarm_args));
 
-		e_cal_component_alarm_set_description (alarm, &description);
+	description.value = text;
+	description.altrep = NULL;
 
-	g_free (str);
+	e_cal_component_alarm_set_description (alarm, &description);
 
 	/* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that
 	 * we don't re-set the alarm's description */
@@ -1040,13 +1036,17 @@ dalarm_description_changed_cb (GtkWidget *widget,
 static void
 check_custom_program (Dialog *dialog)
 {
-	gchar *str;
-	gboolean sens;
+	GtkEntry *entry;
+	const gchar *text;
+	gboolean sensitive;
 
-	str = e_dialog_editable_get (dialog->palarm_program);
+	entry = GTK_ENTRY (dialog->palarm_program);
+	text = gtk_entry_get_text (entry);
+	sensitive = (text != NULL && *text != '\0');
 
-	sens = str && *str;
-	gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->toplevel), GTK_RESPONSE_OK, sens);
+	gtk_dialog_set_response_sensitive (
+		GTK_DIALOG (dialog->toplevel),
+		GTK_RESPONSE_OK, sensitive);
 }
 
 static void
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 11524cd..5152b9a 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -1020,7 +1020,8 @@ event_page_save_locations_list (CompEditorPage *page,
 	GtkTreeIter iter;
 
 	const gchar *cache_dir;
-	gchar *file_name, *current_location;
+	const gchar *current_location;
+	gchar *file_name;
 	GString *contents;
 
 	priv = EVENT_PAGE (page)->priv;
@@ -1040,7 +1041,7 @@ event_page_save_locations_list (CompEditorPage *page,
 		}
 	}
 
-	current_location = e_dialog_editable_get (priv->location);
+	current_location = gtk_entry_get_text (GTK_ENTRY (priv->location));
 
 	/* Put current locatin on the very top of the list */
 	contents = g_string_new (current_location);
@@ -1074,7 +1075,6 @@ event_page_save_locations_list (CompEditorPage *page,
 
 	g_string_free (contents, TRUE);
 	g_free (file_name);
-	g_free (current_location);
 }
 
 static gboolean
@@ -1383,8 +1383,8 @@ event_page_fill_component (CompEditorPage *page,
 
 	/* Summary */
 
-	str = e_dialog_editable_get (priv->summary);
-	if (!str || !*str)
+	str = gtk_editable_get_chars (GTK_EDITABLE (priv->summary), 0, -1);
+	if (str == NULL || *str == '\0')
 		e_cal_component_set_summary (comp, NULL);
 	else {
 		ECalComponentText text;
@@ -1395,21 +1395,19 @@ event_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_summary (comp, &text);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Location */
 
-	str = e_dialog_editable_get (priv->location);
-	if (!str || !*str)
+	str = gtk_editable_get_chars (GTK_EDITABLE (priv->location), 0, -1);
+	if (str == NULL || *str == '\0')
 		e_cal_component_set_location (comp, NULL);
 	else {
 		e_cal_component_set_location (comp, str);
 		event_page_save_locations_list (page, comp);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Description */
 
@@ -1417,7 +1415,7 @@ event_page_fill_component (CompEditorPage *page,
 	gtk_text_buffer_get_end_iter   (text_buffer, &text_iter_end);
 	str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE);
 
-	if (!str || !*str)
+	if (str == NULL || *str == '\0')
 		e_cal_component_set_description_list (comp, NULL);
 	else {
 		GSList l;
@@ -1431,8 +1429,7 @@ event_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_description_list (comp, &l);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Dates */
 
@@ -1501,15 +1498,13 @@ event_page_fill_component (CompEditorPage *page,
 
 	/* Categories */
 
-	cat = e_dialog_editable_get (priv->categories);
+	cat = gtk_editable_get_chars (GTK_EDITABLE (priv->categories), 0, -1);
 	str = comp_editor_strip_categories (cat);
-	if (cat)
-		g_free (cat);
+	g_free (cat);
 
 	e_cal_component_set_categories (comp, str);
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Classification */
 	classification = comp_editor_get_classification (editor);
@@ -2590,19 +2585,18 @@ get_widgets (EventPage *epage)
 }
 
 static void
-summary_changed_cb (GtkEditable *editable,
+summary_changed_cb (GtkEntry *entry,
                     CompEditorPage *page)
 {
 	CompEditor *editor;
-	gchar *summary;
+	const gchar *text;
 
 	if (comp_editor_page_get_updating (page))
 		return;
 
 	editor = comp_editor_page_get_editor (page);
-	summary = e_dialog_editable_get (GTK_WIDGET (editable));
-	comp_editor_set_summary (editor, summary);
-	g_free (summary);
+	text = gtk_entry_get_text (entry);
+	comp_editor_set_summary (editor, text);
 }
 
 /* Note that this assumes that the start_tt and end_tt passed to it are the
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index 3b783d3..4ef58ea 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -652,8 +652,8 @@ memo_page_fill_component (CompEditorPage *page,
 	text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->memo_content));
 
 	/* Summary */
-	str = e_dialog_editable_get (priv->summary_entry);
-	if (!str || strlen (str) == 0)
+	str = gtk_editable_get_chars (GTK_EDITABLE (priv->summary_entry), 0, -1);
+	if (str == NULL || *str == '\0')
 		e_cal_component_set_summary (comp, NULL);
 	else {
 		ECalComponentText text;
@@ -664,10 +664,8 @@ memo_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_summary (comp, &text);
 	}
 
-	if (str) {
-		g_free (str);
-		str = NULL;
-	}
+	g_free (str);
+	str = NULL;
 
 	/* Memo Content */
 
@@ -701,8 +699,7 @@ memo_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_description_list (comp, &l);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Dates */
 	start_tt = icaltime_null_time ();
@@ -727,15 +724,13 @@ memo_page_fill_component (CompEditorPage *page,
 	e_cal_component_set_classification (comp, classification);
 
 	/* Categories */
-	cat = e_dialog_editable_get (priv->categories);
+	cat = gtk_editable_get_chars (GTK_EDITABLE (priv->categories), 0, -1);
 	str = comp_editor_strip_categories (cat);
-	if (cat)
-		g_free (cat);
+	g_free (cat);
 
 	e_cal_component_set_categories (comp, str);
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* change recipients only when creating new item, after that no such action is available */
 	if ((flags & COMP_EDITOR_IS_SHARED) && (flags & COMP_EDITOR_NEW_ITEM) && fill_comp_with_recipients (priv->name_selector, comp)) {
@@ -1026,19 +1021,18 @@ set_subscriber_info_string (MemoPage *mpage,
 }
 
 static void
-summary_changed_cb (GtkEditable *editable,
+summary_changed_cb (GtkEntry *entry,
                     CompEditorPage *page)
 {
 	CompEditor *editor;
-	gchar *summary;
+	const gchar *text;
 
 	if (comp_editor_page_get_updating (page))
 		return;
 
 	editor = comp_editor_page_get_editor (page);
-	summary = e_dialog_editable_get (GTK_WIDGET (editable));
-	comp_editor_set_summary (editor, summary);
-	g_free (summary);
+	text = gtk_entry_get_text (entry);
+	comp_editor_set_summary (editor, text);
 }
 
 static void
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index 71905ce..919a9c0 100644
--- a/calendar/gui/dialogs/task-details-page.c
+++ b/calendar/gui/dialogs/task-details-page.c
@@ -315,7 +315,7 @@ task_details_page_fill_component (CompEditorPage *page,
 	TaskEditorPriority priority;
 	CompEditor *editor;
 	gint priority_value, percent;
-	gchar *url;
+	const gchar *text;
 	gboolean date_set;
 	icaltimezone *zone;
 
@@ -389,10 +389,8 @@ task_details_page_fill_component (CompEditorPage *page,
 	}
 
 	/* URL. */
-	url = e_dialog_editable_get (priv->url);
-	e_cal_component_set_url (comp, url);
-	if (url)
-		g_free (url);
+	text = gtk_entry_get_text (GTK_ENTRY (priv->url));
+	e_cal_component_set_url (comp, text);
 
 	return TRUE;
 }
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index 493af6f..2fe06d9 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -763,8 +763,8 @@ task_page_fill_component (CompEditorPage *page,
 
 	/* Summary. */
 
-	str = e_dialog_editable_get (priv->summary);
-	if (!str || strlen (str) == 0)
+	str = gtk_editable_get_chars (GTK_EDITABLE (priv->summary), 0, -1);
+	if (str == NULL || *str == '\0')
 		e_cal_component_set_summary (comp, NULL);
 	else {
 		ECalComponentText text;
@@ -775,8 +775,7 @@ task_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_summary (comp, &text);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Description */
 
@@ -798,8 +797,7 @@ task_page_fill_component (CompEditorPage *page,
 		e_cal_component_set_description_list (comp, &l);
 	}
 
-	if (str)
-		g_free (str);
+	g_free (str);
 
 	/* Dates */
 
@@ -857,10 +855,9 @@ task_page_fill_component (CompEditorPage *page,
 	}
 
 	/* Categories */
-	cat = e_dialog_editable_get (priv->categories);
+	cat = gtk_editable_get_chars (GTK_EDITABLE (priv->categories), 0, -1);
 	str = comp_editor_strip_categories (cat);
-	if (cat)
-		g_free (cat);
+	g_free (cat);
 
 	e_cal_component_set_categories (comp, str);
 
@@ -1521,19 +1518,18 @@ get_widgets (TaskPage *tpage)
 }
 
 static void
-summary_changed_cb (GtkEditable *editable,
+summary_changed_cb (GtkEntry *entry,
                     CompEditorPage *page)
 {
 	CompEditor *editor;
-	gchar *summary;
+	const gchar *text;
 
 	if (comp_editor_page_get_updating (page))
 		return;
 
 	editor = comp_editor_page_get_editor (page);
-	summary = e_dialog_editable_get (GTK_WIDGET (editable));
-	comp_editor_set_summary (editor, summary);
-	g_free (summary);
+	text = gtk_entry_get_text (entry);
+	comp_editor_set_summary (editor, text);
 }
 
 /* Callback used when the start or due date widgets change.  We notify the
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 137f497..f568705 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -841,7 +841,6 @@ e_datetime_format_format_tm
 <FILE>e-dialog-utils</FILE>
 <TITLE>Dialog Utilities (Legacy)</TITLE>
 e_notice
-e_dialog_editable_get
 e_dialog_combo_box_set
 e_dialog_combo_box_get
 </SECTION>
diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c
index 2b0c20d..a8416ec 100644
--- a/e-util/e-dialog-widgets.c
+++ b/e-util/e-dialog-widgets.c
@@ -70,24 +70,6 @@ index_to_value (const gint *value_map,
 }
 
 /**
- * e_dialog_editable_get:
- * @widget: A #GtkEditable widget.
- *
- * Queries the string value inside a #GtkEditable-derived widget.
- *
- * Return value: String value.  You should free it when you are done with it.
- * This function can return NULL if the string could not be converted from
- * GTK+'s encoding into UTF8.
- **/
-gchar *
-e_dialog_editable_get (GtkWidget *widget)
-{
-	g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL);
-
-	return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
-}
-
-/**
  * e_dialog_combo_box_set:
  * @widget: A #GtkComboBox.
  * @value: Enumerated value.
diff --git a/e-util/e-dialog-widgets.h b/e-util/e-dialog-widgets.h
index 60c30e7..65de4d9 100644
--- a/e-util/e-dialog-widgets.h
+++ b/e-util/e-dialog-widgets.h
@@ -27,8 +27,6 @@
 
 #include <gtk/gtk.h>
 
-gchar *e_dialog_editable_get (GtkWidget *widget);
-
 void e_dialog_combo_box_set (GtkWidget *widget, gint value, const gint *value_map);
 gint e_dialog_combo_box_get (GtkWidget *widget, const gint *value_map);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]