[gnome-control-center] Resync gedit-message-area.[ch] with upstream



commit 8ffc430cb8d033d74c1e904d78d59f8af902ccf0
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Mon Jul 13 15:29:52 2009 +0200

    Resync gedit-message-area.[ch] with upstream
    
    Fixes part of GNOME bug #572325

 capplets/appearance/gedit-message-area.c |  166 +++++++++++++++++++++++-------
 capplets/appearance/gedit-message-area.h |   38 ++++----
 2 files changed, 146 insertions(+), 58 deletions(-)
---
diff --git a/capplets/appearance/gedit-message-area.c b/capplets/appearance/gedit-message-area.c
index c682113..0924051 100644
--- a/capplets/appearance/gedit-message-area.c
+++ b/capplets/appearance/gedit-message-area.c
@@ -25,7 +25,7 @@
  * list of people on the gedit Team.
  * See the ChangeLog files for a list of changes.
  *
- * $Id: gedit-message-area.c 5080 2006-08-09 15:17:37Z pborelli $
+ * $Id$
  */
 
 /* TODO: Style properties */
@@ -152,56 +152,23 @@ paint_message_area (GtkWidget      *widget,
 			    NULL,
 			    widget,
 			    "tooltip",
-			    widget->allocation.x,
-			    widget->allocation.y,
-			    widget->allocation.width,
-			    widget->allocation.height);
+			    widget->allocation.x + 1,
+			    widget->allocation.y + 1,
+			    widget->allocation.width - 2,
+			    widget->allocation.height - 2);
 
 	return FALSE;
 }
 
 static void
-style_set (GtkWidget *widget,
-	   GtkStyle  *prev_style)
-{
-	GtkTooltips *tooltips;
-	GtkStyle *style;
-
-	GeditMessageArea *message_area = GEDIT_MESSAGE_AREA (widget);
-
-	if (message_area->priv->changing_style)
-		return;
-
-	tooltips = gtk_tooltips_new ();
-	g_object_ref_sink (tooltips);
-
-	gtk_tooltips_force_window (tooltips);
-
-  if (GTK_IS_WIDGET (tooltips->tip_window)) {
-		gtk_widget_ensure_style (tooltips->tip_window);
-		style = gtk_widget_get_style (tooltips->tip_window);
-
-  	message_area->priv->changing_style = TRUE;
-  	gtk_widget_set_style (GTK_WIDGET (widget), style);
-  	message_area->priv->changing_style = FALSE;
-	}
-
-	g_object_unref (tooltips);
-}
-
-static void
 gedit_message_area_class_init (GeditMessageAreaClass *klass)
 {
 	GObjectClass *object_class;
-	GtkWidgetClass *widget_class;
 	GtkBindingSet *binding_set;
 
 	object_class = G_OBJECT_CLASS (klass);
-	widget_class = GTK_WIDGET_CLASS (klass);
 	object_class->finalize = gedit_message_area_finalize;
 
-	widget_class->style_set = style_set;
-
 	klass->close = gedit_message_area_close;
 
 	g_type_class_add_private (object_class, sizeof(GeditMessageAreaPrivate));
@@ -229,6 +196,32 @@ gedit_message_area_class_init (GeditMessageAreaClass *klass)
 }
 
 static void
+style_set (GtkWidget        *widget,
+	   GtkStyle         *prev_style,
+	   GeditMessageArea *message_area)
+{
+	GtkWidget *window;
+	GtkStyle *style;
+
+	if (message_area->priv->changing_style)
+		return;
+
+	/* This is a hack needed to use the tooltip background color */
+	window = gtk_window_new (GTK_WINDOW_POPUP);
+	gtk_widget_set_name (window, "gtk-tooltip");
+	gtk_widget_ensure_style (window);
+	style = gtk_widget_get_style (window);
+
+	message_area->priv->changing_style = TRUE;
+	gtk_widget_set_style (GTK_WIDGET (message_area), style);
+	message_area->priv->changing_style = FALSE;
+
+	gtk_widget_destroy (window);
+
+	gtk_widget_queue_draw (GTK_WIDGET (message_area));
+}
+
+static void
 gedit_message_area_init (GeditMessageArea *message_area)
 {
 	message_area->priv = GEDIT_MESSAGE_AREA_GET_PRIVATE (message_area);
@@ -255,9 +248,18 @@ gedit_message_area_init (GeditMessageArea *message_area)
 	gtk_widget_set_app_paintable (GTK_WIDGET (message_area), TRUE);
 
 	g_signal_connect (message_area,
-			  "expose_event",
+			  "expose-event",
 			  G_CALLBACK (paint_message_area),
 			  NULL);
+
+	/* Note that we connect to style-set on one of the internal
+	 * widgets, not on the message area itself, since gtk does
+	 * not deliver any further style-set signals for a widget on
+	 * which the style has been forced with gtk_widget_set_style() */
+	g_signal_connect (message_area->priv->main_hbox,
+			  "style-set",
+			  G_CALLBACK (style_set),
+			  message_area);
 }
 
 static gint
@@ -333,6 +335,13 @@ gedit_message_area_add_action_widget (GeditMessageArea *message_area,
 				    0);
 }
 
+/**
+ * gedit_message_area_set_contents:
+ * @message_area: a #GeditMessageArea
+ * @contents: widget you want to add to the contents area
+ *
+ * Adds the @contents widget to the contents area of #GeditMessageArea.
+ */
 void
 gedit_message_area_set_contents	(GeditMessageArea *message_area,
 				 GtkWidget        *contents)
@@ -348,6 +357,19 @@ gedit_message_area_set_contents	(GeditMessageArea *message_area,
 			    0);
 }
 
+/**
+ * gedit_message_area_add_button:
+ * @message_area: a #GeditMessageArea
+ * @button_text: text of button, or stock ID
+ * @response_id: response ID for the button
+ * 
+ * Adds a button with the given text (or a stock button, if button_text is a stock ID)
+ * and sets things up so that clicking the button will emit the "response" signal
+ * with the given response_id. The button is appended to the end of the message area's
+ * action area. The button widget is returned, but usually you don't need it.
+ *
+ * Returns: the button widget that was added
+ */
 GtkWidget*
 gedit_message_area_add_button (GeditMessageArea *message_area,
 			       const gchar      *button_text,
@@ -401,6 +423,16 @@ add_buttons_valist (GeditMessageArea *message_area,
 	}
 }
 
+/**
+ * gedit_message_area_add_buttons:
+ * @message_area: a #GeditMessageArea
+ * @first_button_text: button text or stock ID
+ * @...: response ID for first button, then more text-response_id pairs
+ *
+ * Adds more buttons, same as calling gedit_message_area_add_button() repeatedly.
+ * The variable argument list should be NULL-terminated as with
+ * gedit_message_area_new_with_buttons(). Each button must have both text and response ID.
+ */
 void
 gedit_message_area_add_buttons (GeditMessageArea *message_area,
 				const gchar      *first_button_text,
@@ -417,12 +449,33 @@ gedit_message_area_add_buttons (GeditMessageArea *message_area,
 	va_end (args);
 }
 
+/**
+ * gedit_message_area_new:
+ * 
+ * Creates a new #GeditMessageArea object.
+ * 
+ * Returns: a new #GeditMessageArea object
+ */
 GtkWidget *
 gedit_message_area_new (void)
 {
 	return g_object_new (GEDIT_TYPE_MESSAGE_AREA, NULL);
 }
 
+/**
+ * gedit_message_area_new_with_buttons:
+ * @first_button_text: stock ID or text to go in first button, or NULL
+ * @...: response ID for first button, then additional buttons, ending with NULL
+ * 
+ * Creates a new #GeditMessageArea with buttons. Button text/response ID pairs 
+ * should be listed, with a NULL pointer ending the list. Button text can be either
+ * a stock ID such as GTK_STOCK_OK, or some arbitrary text. A response ID can be any
+ * positive number, or one of the values in the GtkResponseType enumeration. If 
+ * the user clicks one of these dialog buttons, GeditMessageArea will emit the "response"
+ * signal with the corresponding response ID.
+ *
+ * Returns: a new #GeditMessageArea
+ */
 GtkWidget *
 gedit_message_area_new_with_buttons (const gchar *first_button_text,
                                      ...)
@@ -443,6 +496,16 @@ gedit_message_area_new_with_buttons (const gchar *first_button_text,
 	return GTK_WIDGET (message_area);
 }
 
+/**
+ * gedit_message_area_set_response_sensitive:
+ * @message_area: a #GeditMessageArea
+ * @response_id: a response ID
+ * @setting: TRUE for sensitive
+ *
+ * Calls gtk_widget_set_sensitive (widget, setting) for each widget in the dialog's
+ * action area with the given response_id. A convenient way to sensitize/desensitize
+ * dialog buttons.
+ */
 void
 gedit_message_area_set_response_sensitive (GeditMessageArea *message_area,
 					   gint              response_id,
@@ -470,6 +533,15 @@ gedit_message_area_set_response_sensitive (GeditMessageArea *message_area,
 	g_list_free (children);
 }
 
+/**
+ * gedit_message_area_set_default_response:
+ * @message_area: a #GeditMessageArea
+ * @response_id: a response ID
+ *
+ * Sets the last widget in the message area's action area with the given response_id
+ * as the default widget for the dialog. Pressing "Enter" normally activates the
+ * default widget.
+ */
 void
 gedit_message_area_set_default_response (GeditMessageArea *message_area,
 					 gint              response_id)
@@ -496,6 +568,13 @@ gedit_message_area_set_default_response (GeditMessageArea *message_area,
 	g_list_free (children);
 }
 
+/**
+ * gedit_message_area_set_default_response:
+ * @message_area: a #GeditMessageArea
+ * @response_id: a response ID
+ *
+ * Emits the 'response' signal with the given @response_id.
+ */
 void
 gedit_message_area_response (GeditMessageArea *message_area,
 			     gint              response_id)
@@ -508,6 +587,15 @@ gedit_message_area_response (GeditMessageArea *message_area,
 		       response_id);
 }
 
+/**
+ * gedit_message_area_add_stock_button_with_text:
+ * @message_area: a #GeditMessageArea
+ * @text: the text to visualize in the button
+ * @stock_id: the stock ID of the button
+ * @response_id: a response ID
+ *
+ * Same as gedit_message_area_add_button() but with a specific text.
+ */
 GtkWidget *
 gedit_message_area_add_stock_button_with_text (GeditMessageArea *message_area,
 				    	       const gchar      *text,
diff --git a/capplets/appearance/gedit-message-area.h b/capplets/appearance/gedit-message-area.h
index fb1fff9..01dfff0 100644
--- a/capplets/appearance/gedit-message-area.h
+++ b/capplets/appearance/gedit-message-area.h
@@ -2,7 +2,7 @@
  * gedit-message-area.h
  * This file is part of gedit
  *
- * Copyright (C) 2005 - Paolo Maggi
+ * Copyright (C) 2005 - Paolo Maggi 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,16 +16,16 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Foundation, Inc., 59 Temple Place, Suite 330, 
  * Boston, MA 02111-1307, USA.
  */
-
+ 
 /*
- * Modified by the gedit Team, 2005. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
+ * Modified by the gedit Team, 2005. See the AUTHORS file for a 
+ * list of people on the gedit Team.  
+ * See the ChangeLog files for a list of changes. 
  *
- * $Id: gedit-message-area.h 5666 2007-06-29 19:52:25Z sfre $
+ * $Id$
  */
 
 #ifndef __GEDIT_MESSAGE_AREA_H__
@@ -53,7 +53,7 @@ typedef struct _GeditMessageAreaPrivate GeditMessageAreaPrivate;
  */
 typedef struct _GeditMessageArea GeditMessageArea;
 
-struct _GeditMessageArea
+struct _GeditMessageArea 
 {
 	GtkHBox parent;
 
@@ -66,7 +66,7 @@ struct _GeditMessageArea
  */
 typedef struct _GeditMessageAreaClass GeditMessageAreaClass;
 
-struct _GeditMessageAreaClass
+struct _GeditMessageAreaClass 
 {
 	GtkHBoxClass parent_class;
 
@@ -78,7 +78,7 @@ struct _GeditMessageAreaClass
 
 	/* Padding for future expansion */
 	void (*_gedit_reserved1) (void);
-	void (*_gedit_reserved2) (void);
+	void (*_gedit_reserved2) (void);	
 };
 
 /*
@@ -93,30 +93,30 @@ GtkWidget	*gedit_message_area_new_with_buttons	(const gchar      *first_button_t
 
 void		 gedit_message_area_set_contents	(GeditMessageArea *message_area,
                                              		 GtkWidget        *contents);
-
+                              		 
 void		 gedit_message_area_add_action_widget	(GeditMessageArea *message_area,
                                          		 GtkWidget        *child,
                                          		 gint              response_id);
-
+                                         		 
 GtkWidget	*gedit_message_area_add_button        	(GeditMessageArea *message_area,
                                          		 const gchar      *button_text,
                                          		 gint              response_id);
-
-GtkWidget	*gedit_message_area_add_stock_button_with_text
-							(GeditMessageArea *message_area,
-				    			 const gchar      *text,
-				    			 const gchar      *stock_id,
+             		 
+GtkWidget	*gedit_message_area_add_stock_button_with_text 
+							(GeditMessageArea *message_area, 
+				    			 const gchar      *text, 
+				    			 const gchar      *stock_id, 
 				    			 gint              response_id);
 
 void       	 gedit_message_area_add_buttons 	(GeditMessageArea *message_area,
                                          		 const gchar      *first_button_text,
                                          		 ...);
 
-void		 gedit_message_area_set_response_sensitive
+void		 gedit_message_area_set_response_sensitive 
 							(GeditMessageArea *message_area,
                                         		 gint              response_id,
                                         		 gboolean          setting);
-void 		 gedit_message_area_set_default_response
+void 		 gedit_message_area_set_default_response 
 							(GeditMessageArea *message_area,
                                         		 gint              response_id);
 



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