[evolution-patches] [Fwd: [Evolution-hackers] Make attachment properties instant apply + HIGgy]



-------- Weitergeleitete Nachricht --------
> Von: Christian Neumair <chris gnome-de org>
> An: evolution-hackers lists ximian com
> Betreff: [Evolution-hackers] Make attachment properties instant apply
> + HIGgy
> Datum: Wed, 02 Jun 2004 14:31:57 +0200
> The attached patch makes the attachment property dialog instant apply
> and is a first shot at making it HIG compliant. The MIME entry has been
> replaced by a label because it isn't editable at the moment and most
> probably we won't get a nice MIME type picker for the next few months.

Sorry, wrong list.
Index: composer/e-msg-composer-attachment.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-attachment.c,v
retrieving revision 1.52
diff -u -r1.52 e-msg-composer-attachment.c
--- composer/e-msg-composer-attachment.c	31 Mar 2004 10:08:03 -0000	1.52
+++ composer/e-msg-composer-attachment.c	2 Jun 2004 12:30:03 -0000
@@ -33,6 +33,7 @@
 #include <errno.h>
 
 #include <camel/camel.h>
+#include <gtk/gtklabel.h>
 #include <gtk/gtknotebook.h>
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkdialog.h>
@@ -284,8 +285,8 @@
 	GtkWidget *dialog;
 	GtkEntry *file_name_entry;
 	GtkEntry *description_entry;
-	GtkEntry *mime_type_entry;
-	GtkToggleButton *disposition_checkbox;
+	GtkLabel *mime_type_label;
+	GtkToggleButton *disposition_toggle_button;
 	EMsgComposerAttachment *attachment;
 } DialogData;
 
@@ -302,15 +303,14 @@
  */
 
 static void
-set_entry (GladeXML *xml, const char *widget_name, const char *value)
+set_widget_value (GtkWidget *widget, const char *value)
 {
-	GtkEntry *entry;
-	
-	entry = GTK_ENTRY (glade_xml_get_widget (xml, widget_name));
-	if (entry == NULL)
-		g_warning ("Entry for `%s' not found.", widget_name);
-	else
-		gtk_entry_set_text (entry, value ? value : "");
+	g_return_if_fail (widget != NULL);
+
+	if (GTK_IS_ENTRY (widget))
+		gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
+	else if (GTK_IS_LABEL (widget))
+		gtk_label_set_text (GTK_LABEL (widget), value ? value : "");
 }
 
 static void
@@ -342,49 +342,55 @@
 }
 
 static void
-ok_cb (GtkWidget *widget, gpointer data)
+response_cb (GtkWidget *widget, gint response, gpointer data)
+{
+	close_cb (widget, data);
+}
+
+static void
+file_name_entry_changed_cb (GtkEntry *entry, gpointer data)
 {
-	DialogData *dialog_data;
 	EMsgComposerAttachment *attachment;
 	const char *str;
-	
-	dialog_data = (DialogData *) data;
-	attachment = dialog_data->attachment;
-	
-	str = gtk_entry_get_text (dialog_data->file_name_entry);
+
+	attachment = (EMsgComposerAttachment *) data;
+
+	str = gtk_entry_get_text (entry);
 	camel_mime_part_set_filename (attachment->body, str);
-	
-	str = gtk_entry_get_text (dialog_data->description_entry);
+
+	changed (attachment);
+}
+
+static void
+description_entry_changed_cb (GtkEntry *entry, gpointer data)
+{
+	EMsgComposerAttachment *attachment;
+	const char *str;
+
+	attachment = (EMsgComposerAttachment *) data;
+
+	str = gtk_entry_get_text (entry);
 	camel_mime_part_set_description (attachment->body, str);
-	
-	str = gtk_entry_get_text (dialog_data->mime_type_entry);
-	camel_mime_part_set_content_type (attachment->body, str);
-	
-	camel_data_wrapper_set_mime_type(camel_medium_get_content_object(CAMEL_MEDIUM (attachment->body)), str);
-	
-	switch (gtk_toggle_button_get_active (dialog_data->disposition_checkbox)) {
-	case 0:
-		camel_mime_part_set_disposition (attachment->body, "attachment");
-		break;
-	case 1:
-		camel_mime_part_set_disposition (attachment->body, "inline");
-		break;
-	default:
-		/* Hmmmm? */
-		break;
-	}
-	
+
 	changed (attachment);
-	close_cb (widget, data);
 }
 
 static void
-response_cb (GtkWidget *widget, gint response, gpointer data)
+disposition_toggle_button_toggled_cb (GtkToggleButton *button, gpointer data)
 {
-	if (response == GTK_RESPONSE_OK)
-		ok_cb (widget, data);
+	EMsgComposerAttachment *attachment;
+	gboolean active = FALSE;
+
+	attachment = (EMsgComposerAttachment *) data;
+
+	active = gtk_toggle_button_get_active (button);
+
+	if (active)
+		camel_mime_part_set_disposition (attachment->body, "inline");
 	else
-		close_cb (widget, data);
+		camel_mime_part_set_disposition (attachment->body, "attachment");
+
+	changed (attachment);
 }
 
 void
@@ -395,7 +401,7 @@
 	DialogData *dialog_data;
 	GladeXML *editor_gui;
 	char *type;
-	
+
 	g_return_if_fail (attachment != NULL);
 	g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT (attachment));
 	
@@ -429,22 +435,30 @@
 		glade_xml_get_widget (editor_gui, "file_name_entry"));
 	dialog_data->description_entry = GTK_ENTRY (
 		glade_xml_get_widget (editor_gui, "description_entry"));
-	dialog_data->mime_type_entry = GTK_ENTRY (
-		glade_xml_get_widget (editor_gui, "mime_type_entry"));
-	dialog_data->disposition_checkbox = GTK_TOGGLE_BUTTON (
-		glade_xml_get_widget (editor_gui, "disposition_checkbox"));
-	
-	set_entry (editor_gui, "file_name_entry",
-		   camel_mime_part_get_filename (attachment->body));
-	set_entry (editor_gui, "description_entry",
-		   camel_mime_part_get_description (attachment->body));
+	dialog_data->mime_type_label = GTK_LABEL (
+		glade_xml_get_widget (editor_gui, "mime_type_label"));
+	dialog_data->disposition_toggle_button = GTK_TOGGLE_BUTTON (
+		glade_xml_get_widget (editor_gui, "disposition_toggle_button"));
+	
+	set_widget_value (GTK_WIDGET (dialog_data->file_name_entry),
+			  camel_mime_part_get_filename (attachment->body));
+	set_widget_value (GTK_WIDGET (dialog_data->description_entry),
+			  camel_mime_part_get_description (attachment->body));
+
 	content_type = camel_mime_part_get_content_type (attachment->body);
 	type = camel_content_type_simple (content_type);
-	set_entry (editor_gui, "mime_type_entry", type);
+	set_widget_value (GTK_WIDGET (dialog_data->mime_type_label), type);
 	g_free (type);
+
+	g_signal_connect (dialog_data->file_name_entry, "changed",
+			  G_CALLBACK (file_name_entry_changed_cb), attachment);
+	g_signal_connect (dialog_data->description_entry, "changed",
+			  G_CALLBACK (description_entry_changed_cb), attachment);
+	g_signal_connect (dialog_data->disposition_toggle_button, "toggled",
+			  G_CALLBACK (disposition_toggle_button_toggled_cb), attachment);
 	
 	disposition = camel_mime_part_get_disposition (attachment->body);
-	gtk_toggle_button_set_active (dialog_data->disposition_checkbox,
+	gtk_toggle_button_set_active (dialog_data->disposition_toggle_button,
 				      disposition && !g_ascii_strcasecmp (disposition, "inline"));
 	
 	connect_widget (editor_gui, "dialog", "response", (GCallback)response_cb, dialog_data);
Index: composer/e-msg-composer-attachment.glade
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-attachment.glade,v
retrieving revision 1.10
diff -u -r1.10 e-msg-composer-attachment.glade
--- composer/e-msg-composer-attachment.glade	21 Apr 2003 17:45:52 -0000	1.10
+++ composer/e-msg-composer-attachment.glade	2 Jun 2004 12:30:03 -0000
@@ -4,49 +4,37 @@
 <glade-interface>
 
 <widget class="GtkDialog" id="dialog">
-  <property name="border_width">6</property>
+  <property name="border_width">5</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Attachment Properties</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="window_position">GTK_WIN_POS_NONE</property>
   <property name="modal">False</property>
-  <property name="resizable">True</property>
+  <property name="resizable">False</property>
   <property name="destroy_with_parent">False</property>
-  <property name="has_separator">True</property>
+  <property name="has_separator">False</property>
 
   <child internal-child="vbox">
-    <widget class="GtkVBox" id="dialog-vbox1">
+    <widget class="GtkVBox" id="vbox">
       <property name="visible">True</property>
       <property name="homogeneous">False</property>
-      <property name="spacing">6</property>
+      <property name="spacing">2</property>
 
       <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="dialog-action_area1">
+	<widget class="GtkHButtonBox" id="hbbox">
 	  <property name="visible">True</property>
 	  <property name="layout_style">GTK_BUTTONBOX_END</property>
 
 	  <child>
-	    <widget class="GtkButton" id="close_button">
+	    <widget class="GtkButton" id="button">
 	      <property name="visible">True</property>
 	      <property name="can_default">True</property>
 	      <property name="has_default">True</property>
 	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
+	      <property name="label">gtk-close</property>
 	      <property name="use_stock">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">-6</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="ok_button">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">-5</property>
+	      <property name="response_id">-7</property>
 	    </widget>
 	  </child>
 	</widget>
@@ -59,41 +47,45 @@
       </child>
 
       <child>
-	<widget class="GtkTable" id="table1">
+	<widget class="GtkTable" id="table">
+	  <property name="border_width">5</property>
 	  <property name="visible">True</property>
 	  <property name="n_rows">4</property>
 	  <property name="n_columns">2</property>
 	  <property name="homogeneous">False</property>
 	  <property name="row_spacing">6</property>
-	  <property name="column_spacing">6</property>
+	  <property name="column_spacing">12</property>
 
 	  <child>
-	    <widget class="GtkEntry" id="description_entry">
+	    <widget class="GtkLabel" id="label">
 	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">True</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</property>
-	      <property name="invisible_char" translatable="yes">*</property>
-	      <property name="activates_default">False</property>
+	      <property name="label" translatable="yes">_Filename:</property>
+	      <property name="use_underline">True</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_CENTER</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="mnemonic_widget">file_name_entry</property>
 	    </widget>
 	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">1</property>
-	      <property name="bottom_attach">2</property>
+	      <property name="left_attach">0</property>
+	      <property name="right_attach">1</property>
+	      <property name="top_attach">0</property>
+	      <property name="bottom_attach">1</property>
+	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkEntry" id="mime_type_entry">
+	    <widget class="GtkEntry" id="file_name_entry">
 	      <property name="visible">True</property>
-	      <property name="sensitive">False</property>
 	      <property name="can_focus">True</property>
-	      <property name="editable">False</property>
+	      <property name="editable">True</property>
 	      <property name="visibility">True</property>
 	      <property name="max_length">0</property>
 	      <property name="text" translatable="yes"></property>
@@ -104,121 +96,124 @@
 	    <packing>
 	      <property name="left_attach">1</property>
 	      <property name="right_attach">2</property>
-	      <property name="top_attach">2</property>
-	      <property name="bottom_attach">3</property>
+	      <property name="top_attach">0</property>
+	      <property name="bottom_attach">1</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkLabel" id="mime_label">
+	    <widget class="GtkLabel" id="label">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">MIME type:</property>
-	      <property name="use_underline">False</property>
+	      <property name="label" translatable="yes">_Description:</property>
+	      <property name="use_underline">True</property>
 	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="justify">GTK_JUSTIFY_CENTER</property>
 	      <property name="wrap">False</property>
 	      <property name="selectable">False</property>
-	      <property name="xalign">1</property>
+	      <property name="xalign">0</property>
 	      <property name="yalign">0.5</property>
 	      <property name="xpad">0</property>
 	      <property name="ypad">0</property>
+	      <property name="mnemonic_widget">description_entry</property>
 	    </widget>
 	    <packing>
 	      <property name="left_attach">0</property>
 	      <property name="right_attach">1</property>
-	      <property name="top_attach">2</property>
-	      <property name="bottom_attach">3</property>
+	      <property name="top_attach">1</property>
+	      <property name="bottom_attach">2</property>
 	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkLabel" id="description_label">
+	    <widget class="GtkEntry" id="description_entry">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Description:</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">1</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
+	      <property name="can_focus">True</property>
+	      <property name="editable">True</property>
+	      <property name="visibility">True</property>
+	      <property name="max_length">0</property>
+	      <property name="text" translatable="yes"></property>
+	      <property name="has_frame">True</property>
+	      <property name="invisible_char" translatable="yes">*</property>
+	      <property name="activates_default">False</property>
 	    </widget>
 	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
 	      <property name="top_attach">1</property>
 	      <property name="bottom_attach">2</property>
-	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkLabel" id="filename_label">
+	    <widget class="GtkLabel" id="label">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">File name:</property>
-	      <property name="use_underline">False</property>
+	      <property name="label" translatable="yes">MIME type:</property>
+	      <property name="use_underline">True</property>
 	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
 	      <property name="wrap">False</property>
 	      <property name="selectable">False</property>
-	      <property name="xalign">1</property>
+	      <property name="xalign">0</property>
 	      <property name="yalign">0.5</property>
 	      <property name="xpad">0</property>
 	      <property name="ypad">0</property>
+	      <property name="mnemonic_widget">mime_type_label</property>
 	    </widget>
 	    <packing>
 	      <property name="left_attach">0</property>
 	      <property name="right_attach">1</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
+	      <property name="top_attach">2</property>
+	      <property name="bottom_attach">3</property>
 	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkEntry" id="file_name_entry">
+	    <widget class="GtkCheckButton" id="disposition_toggle_button">
 	      <property name="visible">True</property>
 	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">True</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</property>
-	      <property name="invisible_char" translatable="yes">*</property>
-	      <property name="activates_default">False</property>
+	      <property name="label" translatable="yes">Suggest _automatic display of attachment</property>
+	      <property name="use_underline">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="active">False</property>
+	      <property name="inconsistent">False</property>
+	      <property name="draw_indicator">True</property>
 	    </widget>
 	    <packing>
-	      <property name="left_attach">1</property>
+	      <property name="left_attach">0</property>
 	      <property name="right_attach">2</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
+	      <property name="top_attach">3</property>
+	      <property name="bottom_attach">4</property>
+	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkCheckButton" id="disposition_checkbox">
+	    <widget class="GtkLabel" id="mime_type_label">
 	      <property name="visible">True</property>
 	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">Suggest automatic display of attachment</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="active">False</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
+	      <property name="label" translatable="yes"></property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">True</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
 	    </widget>
 	    <packing>
-	      <property name="left_attach">0</property>
+	      <property name="left_attach">1</property>
 	      <property name="right_attach">2</property>
-	      <property name="top_attach">3</property>
-	      <property name="bottom_attach">4</property>
+	      <property name="top_attach">2</property>
+	      <property name="bottom_attach">3</property>
 	      <property name="x_options">fill</property>
 	      <property name="y_options"></property>
 	    </packing>
Index: composer/e-msg-composer-select-file.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-select-file.c,v
retrieving revision 1.27
diff -u -r1.27 e-msg-composer-select-file.c
--- composer/e-msg-composer-select-file.c	19 Apr 2004 15:20:26 -0000	1.27
+++ composer/e-msg-composer-select-file.c	2 Jun 2004 12:30:03 -0000
@@ -71,7 +71,7 @@
 	}
 
 	if (showinline_p) {
-		showinline = gtk_check_button_new_with_label (_("Suggest automatic display of attachment"));
+		showinline = gtk_check_button_new_with_mnemonic (_("Suggest _automatic display of attachment"));
 		gtk_widget_show (showinline);
 		gtk_box_pack_end (GTK_BOX (selection->main_vbox), showinline, FALSE, FALSE, 4);
 	}


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