[gedit] Fix some coding style issues
- From: Paolo Borelli <pborelli src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit] Fix some coding style issues
- Date: Wed, 19 Aug 2009 12:51:45 +0000 (UTC)
commit 1b883d0341373b17721af7b162f6ed50fdb1ea3d
Author: Paolo Borelli <pborelli gnome org>
Date: Wed Aug 19 14:51:52 2009 +0200
Fix some coding style issues
gedit/gedit-gio-document-loader.c | 2 +-
gedit/gedit-io-error-message-area.c | 7 +-
gedit/gedit-plugins-engine.c | 17 +++-
gedit/gedit-status-combo-box.c | 179 +++++++++++++++++------------------
4 files changed, 105 insertions(+), 100 deletions(-)
---
diff --git a/gedit/gedit-gio-document-loader.c b/gedit/gedit-gio-document-loader.c
index 03a336e..1bc65bb 100644
--- a/gedit/gedit-gio-document-loader.c
+++ b/gedit/gedit-gio-document-loader.c
@@ -201,9 +201,9 @@ async_read_cb (GInputStream *stream,
AsyncData *async)
{
gedit_debug (DEBUG_LOADER);
- GError *error = NULL;
GeditGioDocumentLoader *gvloader;
gssize bytes_read;
+ GError *error = NULL;
/* manually check cancelled state */
if (g_cancellable_is_cancelled (async->cancellable))
diff --git a/gedit/gedit-io-error-message-area.c b/gedit/gedit-io-error-message-area.c
index 534ca62..188c020 100644
--- a/gedit/gedit-io-error-message-area.c
+++ b/gedit/gedit-io-error-message-area.c
@@ -275,10 +275,13 @@ parse_gio_error (gint code,
{
if (hn != NULL)
{
- gchar *host_name = gedit_utils_make_valid_utf8 (hn);
+ gchar *host_markup;
+ gchar *host_name;
+
+ host_name = gedit_utils_make_valid_utf8 (hn);
g_free (hn);
- gchar *host_markup = g_markup_printf_escaped ("<i>%s</i>", host_name);
+ host_markup = g_markup_printf_escaped ("<i>%s</i>", host_name);
g_free (host_name);
/* Translators: %s is a host name */
diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c
index 6974139..d3d5270 100644
--- a/gedit/gedit-plugins-engine.c
+++ b/gedit/gedit-plugins-engine.c
@@ -591,13 +591,17 @@ static void
gedit_plugins_engine_activate_plugin_real (GeditPluginsEngine *engine,
GeditPluginInfo *info)
{
+ const GList *wins;
+
if (!load_plugin (engine, info))
return;
- /* activate plugin for all windows */
- const GList *wins = gedit_app_get_windows (gedit_app_get_default ());
- for (; wins != NULL; wins = wins->next)
+ for (wins = gedit_app_get_windows (gedit_app_get_default ());
+ wins != NULL;
+ wins = wins->next)
+ {
gedit_plugin_activate (info->plugin, GEDIT_WINDOW (wins->data));
+ }
}
gboolean
@@ -646,9 +650,12 @@ gedit_plugins_engine_deactivate_plugin_real (GeditPluginsEngine *engine,
!gedit_plugin_info_is_available (info))
return;
- wins = gedit_app_get_windows (gedit_app_get_default ());
- for (; wins != NULL; wins = wins->next)
+ for (wins = gedit_app_get_windows (gedit_app_get_default ());
+ wins != NULL;
+ wins = wins->next)
+ {
call_plugin_deactivate (info->plugin, GEDIT_WINDOW (wins->data));
+ }
/* first unref the plugin (the loader still has one) */
g_object_unref (info->plugin);
diff --git a/gedit/gedit-status-combo-box.c b/gedit/gedit-status-combo-box.c
index 1158c52..e1f4cd6 100644
--- a/gedit/gedit-status-combo-box.c
+++ b/gedit/gedit-status-combo-box.c
@@ -56,17 +56,6 @@ enum
static guint signals[NUM_SIGNALS] = { 0 };
-static void menu_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- GeditStatusComboBox *combo);
-static void button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- GeditStatusComboBox *combo);
-static void item_activated (GtkMenuItem *item,
- GeditStatusComboBox *combo);
-
G_DEFINE_TYPE(GeditStatusComboBox, gedit_status_combo_box, GTK_TYPE_EVENT_BOX)
static void
@@ -177,11 +166,86 @@ menu_deactivate (GtkMenu *menu,
}
static void
-gedit_status_combo_box_init (GeditStatusComboBox *self)
+menu_position_func (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ GeditStatusComboBox *combo)
+{
+ GtkRequisition request;
+
+ *push_in = FALSE;
+
+ gtk_widget_size_request (gtk_widget_get_toplevel (GTK_WIDGET (menu)), &request);
+
+ /* get the origin... */
+ gdk_window_get_origin (GTK_WIDGET (combo)->window, x, y);
+
+ /* make the menu as wide as the widget */
+ if (request.width < GTK_WIDGET (combo)->allocation.width)
+ {
+ gtk_widget_set_size_request (GTK_WIDGET (menu), GTK_WIDGET (combo)->allocation.width, -1);
+ }
+
+ /* position it above the widget */
+ *y -= request.height;
+}
+
+static void
+button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ GeditStatusComboBox *combo)
+{
+ GtkRequisition request;
+ gint max_height;
+
+ gtk_widget_size_request (combo->priv->menu, &request);
+
+ /* do something relative to our own height here, maybe we can do better */
+ max_height = GTK_WIDGET (combo)->allocation.height * 20;
+
+ if (request.height > max_height)
+ {
+ gtk_widget_set_size_request (combo->priv->menu, -1, max_height);
+ gtk_widget_set_size_request (gtk_widget_get_toplevel (combo->priv->menu), -1, max_height);
+ }
+
+ gtk_menu_popup (GTK_MENU (combo->priv->menu),
+ NULL,
+ NULL,
+ (GtkMenuPositionFunc)menu_position_func,
+ combo,
+ event->button,
+ event->time);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo->priv->button), TRUE);
+
+ if (combo->priv->current_item)
+ {
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (combo->priv->menu),
+ combo->priv->current_item);
+ }
+}
+
+static void
+set_shadow_type (GeditStatusComboBox *combo)
{
GtkShadowType shadow_type;
GtkWidget *statusbar;
+ /* This is a hack needed to use the shadow type of a statusbar */
+ statusbar = gtk_statusbar_new ();
+ gtk_widget_ensure_style (statusbar);
+
+ gtk_widget_style_get (statusbar, "shadow-type", &shadow_type, NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (combo->priv->frame), shadow_type);
+
+ gtk_widget_destroy (statusbar);
+}
+
+static void
+gedit_status_combo_box_init (GeditStatusComboBox *self)
+{
self->priv = GEDIT_STATUS_COMBO_BOX_GET_PRIVATE (self);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE);
@@ -193,16 +257,9 @@ gedit_status_combo_box_init (GeditStatusComboBox *self)
gtk_widget_set_name (self->priv->button, "gedit-status-combo-button");
gtk_button_set_relief (GTK_BUTTON (self->priv->button), GTK_RELIEF_NONE);
gtk_widget_show (self->priv->button);
-
- /* This is a hack needed to use the shadow type of a statusbar */
- statusbar = gtk_statusbar_new ();
- gtk_widget_ensure_style (statusbar);
- gtk_widget_style_get (statusbar, "shadow-type", &shadow_type, NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (self->priv->frame), shadow_type);
+ set_shadow_type (self);
- gtk_widget_destroy (statusbar);
-
self->priv->hbox = gtk_hbox_new (FALSE, 3);
gtk_widget_show (self->priv->hbox);
@@ -234,12 +291,11 @@ gedit_status_combo_box_init (GeditStatusComboBox *self)
self->priv->menu = gtk_menu_new ();
g_object_ref_sink (self->priv->menu);
-
+
g_signal_connect (self->priv->button,
"button-press-event",
G_CALLBACK (button_press_event),
self);
-
g_signal_connect (self->priv->menu,
"deactivate",
G_CALLBACK (menu_deactivate),
@@ -257,8 +313,9 @@ void
gedit_status_combo_box_set_label (GeditStatusComboBox *combo,
const gchar *label)
{
- g_return_if_fail (GEDIT_IS_STATUS_COMBO_BOX (combo));
gchar *text;
+
+ g_return_if_fail (GEDIT_IS_STATUS_COMBO_BOX (combo));
text = g_strconcat (" ", label, ": ", NULL);
gtk_label_set_markup (GTK_LABEL (combo->priv->label), text);
@@ -273,6 +330,13 @@ gedit_status_combo_box_get_label (GeditStatusComboBox *combo)
return gtk_label_get_label (GTK_LABEL (combo->priv->label));
}
+static void
+item_activated (GtkMenuItem *item,
+ GeditStatusComboBox *combo)
+{
+ gedit_status_combo_box_set_item (combo, item);
+}
+
void
gedit_status_combo_box_add_item (GeditStatusComboBox *combo,
GtkMenuItem *item,
@@ -341,72 +405,3 @@ gedit_status_combo_box_get_item_label (GeditStatusComboBox *combo)
return GTK_LABEL (combo->priv->item);
}
-/* callbacks */
-static void
-button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- GeditStatusComboBox *combo)
-{
- GtkRequisition request;
- gint max_height;
-
- gtk_widget_size_request (combo->priv->menu, &request);
-
- /* do something relative to our own height here, maybe we can do better */
- max_height = GTK_WIDGET (combo)->allocation.height * 20;
-
- if (request.height > max_height)
- {
- gtk_widget_set_size_request (combo->priv->menu, -1, max_height);
- gtk_widget_set_size_request (gtk_widget_get_toplevel (combo->priv->menu), -1, max_height);
- }
-
- gtk_menu_popup (GTK_MENU (combo->priv->menu),
- NULL,
- NULL,
- (GtkMenuPositionFunc)menu_position_func,
- combo,
- event->button,
- event->time);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo->priv->button), TRUE);
-
- if (combo->priv->current_item)
- {
- gtk_menu_shell_select_item (GTK_MENU_SHELL (combo->priv->menu),
- combo->priv->current_item);
- }
-}
-
-static void
-menu_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- GeditStatusComboBox *combo)
-{
- GtkRequisition request;
-
- *push_in = FALSE;
-
- gtk_widget_size_request (gtk_widget_get_toplevel (GTK_WIDGET (menu)), &request);
-
- /* get the origin... */
- gdk_window_get_origin (GTK_WIDGET (combo)->window, x, y);
-
- /* make the menu as wide as the widget */
- if (request.width < GTK_WIDGET (combo)->allocation.width)
- {
- gtk_widget_set_size_request (GTK_WIDGET (menu), GTK_WIDGET (combo)->allocation.width, -1);
- }
-
- /* position it above the widget */
- *y -= request.height;
-}
-
-static void
-item_activated (GtkMenuItem *item,
- GeditStatusComboBox *combo)
-{
- gedit_status_combo_box_set_item (combo, item);
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]