devhelp r1093 - in trunk: . src
- From: rhult svn gnome org
- To: svn-commits-list gnome org
- Subject: devhelp r1093 - in trunk: . src
- Date: Thu, 2 Oct 2008 19:29:53 +0000 (UTC)
Author: rhult
Date: Thu Oct 2 19:29:53 2008
New Revision: 1093
URL: http://svn.gnome.org/viewvc/devhelp?rev=1093&view=rev
Log:
2008-10-02 Richard Hult <richard imendio com>
* src/dh-search.c:
* src/dh-search.h: Add private instance data and fixup
whitepace/style.
Modified:
trunk/ChangeLog
trunk/src/dh-search.c
trunk/src/dh-search.h
Modified: trunk/src/dh-search.c
==============================================================================
--- trunk/src/dh-search.c (original)
+++ trunk/src/dh-search.c Thu Oct 2 19:29:53 2008
@@ -35,14 +35,12 @@
#define d(x)
-typedef enum _DhSearchSource DhSearchSource;
-
-enum _DhSearchSource {
+typedef enum {
SEARCH_API = 0,
SEARCH_ENTRY
-};
+} DhSearchSource;
-struct _DhSearchPriv {
+typedef struct {
DhKeywordModel *model;
DhLink *selected_link;
@@ -68,11 +66,10 @@
GString *entry_str;
DhSearchSource search_source;
-};
-
+} DhSearchPriv;
-static void search_init (DhSearch *search);
-static void search_class_init (DhSearchClass *klass);
+static void dh_search_init (DhSearch *search);
+static void dh_search_class_init (DhSearchClass *klass);
static void search_finalize (GObject *object);
static void search_advanced_options_setup (DhSearch *search);
static void search_advanced_options_notify_cb (GConfClient *client,
@@ -106,44 +103,19 @@
LAST_SIGNAL
};
-static GtkVBox *parent_class;
-static gint signals[LAST_SIGNAL] = { 0 };
+G_DEFINE_TYPE (DhSearch, dh_search, GTK_TYPE_VBOX);
-GType
-dh_search_get_type (void)
-{
- static GType type = 0;
+#define GET_PRIVATE(instance) G_TYPE_INSTANCE_GET_PRIVATE \
+ (instance, DH_TYPE_SEARCH, DhSearchPriv);
- if (!type) {
- static const GTypeInfo info =
- {
- sizeof (DhSearchClass),
- NULL,
- NULL,
- (GClassInitFunc) search_class_init,
- NULL,
- NULL,
- sizeof (DhSearch),
- 0,
- (GInstanceInitFunc) search_init,
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX,
- "DhSearch",
- &info, 0);
- }
-
- return type;
-}
+static gint signals[LAST_SIGNAL] = { 0 };
static void
-search_class_init (DhSearchClass *klass)
+dh_search_class_init (DhSearchClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- parent_class = g_type_class_peek_parent (klass);
-
object_class = (GObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
@@ -158,15 +130,16 @@
_dh_marshal_VOID__POINTER,
G_TYPE_NONE,
1, G_TYPE_POINTER);
+
+ g_type_class_add_private (klass, sizeof (DhSearchPriv));
}
static void
-search_init (DhSearch *search)
+dh_search_init (DhSearch *search)
{
DhSearchPriv *priv;
- priv = g_new0 (DhSearchPriv, 1);
- search->priv = priv;
+ priv = GET_PRIVATE (search);
priv->book_str = g_string_new ("");
priv->page_str = g_string_new ("");
@@ -195,7 +168,7 @@
DhSearchPriv *priv;
GConfClient *gconf_client;
- priv = DH_SEARCH (object)->priv;
+ priv = GET_PRIVATE (object);
g_string_free (priv->book_str, TRUE);
g_string_free (priv->page_str, TRUE);
@@ -206,18 +179,16 @@
gconf_client = dh_base_get_gconf_client (dh_base_get ());
gconf_client_notify_remove (gconf_client, priv->advanced_options_id);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (dh_search_parent_class)->finalize (object);
}
static void
search_advanced_options_setup (DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
gboolean advanced_options;
GConfClient *gconf_client;
- priv = search->priv;
-
gconf_client = dh_base_get_gconf_client (dh_base_get ());
advanced_options = gconf_client_get_bool (gconf_client,
@@ -245,16 +216,16 @@
}
static void
-search_advanced_options_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+search_advanced_options_notify_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
DhSearch *search;
DhSearchPriv *priv;
search = DH_SEARCH (user_data);
- priv = search->priv;
+ priv = GET_PRIVATE (search);
search_advanced_options_setup (search);
@@ -263,12 +234,13 @@
}
static void
-search_selection_changed_cb (GtkTreeSelection *selection, DhSearch *search)
+search_selection_changed_cb (GtkTreeSelection *selection,
+ DhSearch *search)
{
DhSearchPriv *priv;
GtkTreeIter iter;
- priv = search->priv;
+ priv = GET_PRIVATE (search);
if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
DhLink *link;
@@ -301,7 +273,7 @@
DhSearchPriv *priv;
DhLink *link;
- priv = search->priv;
+ priv = GET_PRIVATE (search);
gtk_tree_view_get_path_at_pos (view, event->x, event->y, &path,
NULL, NULL, NULL);
@@ -332,9 +304,7 @@
GdkEventKey *event,
DhSearch *search)
{
- DhSearchPriv *priv;
-
- priv = search->priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
if (event->keyval == GDK_Tab) {
if (event->state & GDK_CONTROL_MASK) {
@@ -378,11 +348,9 @@
static gchar *
search_get_search_string (DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);;
GString *string;
- priv = search->priv;
-
string = g_string_new ("");
if (GTK_WIDGET_VISIBLE (priv->advanced_box) ||
@@ -408,12 +376,11 @@
}
static void
-search_update_string (DhSearch *search, GtkEntry *entry)
+search_update_string (DhSearch *search,
+ GtkEntry *entry)
{
const gchar *str = gtk_entry_get_text (entry);
- DhSearchPriv *priv;
-
- priv = search->priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
priv->search_source = SEARCH_ENTRY;
@@ -443,12 +410,11 @@
}
static void
-search_entry_changed_cb (GtkEntry *entry, DhSearch *search)
+search_entry_changed_cb (GtkEntry *entry,
+ DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
- priv = search->priv;
-
d(g_print ("Entry changed\n"));
search_update_string (search, entry);
@@ -460,14 +426,13 @@
}
static void
-search_entry_activated_cb (GtkEntry *entry, DhSearch *search)
+search_entry_activated_cb (GtkEntry *entry,
+ DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
DhLink *link;
gchar *str;
- priv = search->priv;
-
str = search_get_search_string (search);
link = dh_keyword_model_filter (priv->model, str);
@@ -481,9 +446,7 @@
gint *position,
DhSearch *search)
{
- DhSearchPriv *priv;
-
- priv = search->priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
if (!priv->idle_complete) {
priv->idle_complete =
@@ -495,14 +458,12 @@
static gboolean
search_complete_idle (DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
const gchar *text;
gchar *completed = NULL;
GList *list;
gint text_length;
- priv = search->priv;
-
text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
list = g_completion_complete (priv->completion,
@@ -527,12 +488,10 @@
static gboolean
search_filter_idle (DhSearch *search)
{
- DhSearchPriv *priv;
+ DhSearchPriv *priv = GET_PRIVATE (search);
gchar *str;
DhLink *link;
- priv = search->priv;
-
d(g_print ("Filter idle\n"));
str = search_get_search_string (search);
@@ -568,7 +527,7 @@
GdkColor *color;
search = data;
- priv = search->priv;
+ priv = GET_PRIVATE (search);
gtk_tree_model_get (tree_model, iter,
DH_KEYWORD_MODEL_COL_NAME, &name,
@@ -605,7 +564,7 @@
search = g_object_new (DH_TYPE_SEARCH, NULL);
- priv = search->priv;
+ priv = GET_PRIVATE (search);
gtk_container_set_border_width (GTK_CONTAINER (search), 2);
@@ -735,7 +694,8 @@
}
void
-dh_search_set_search_string (DhSearch *search, const gchar *str)
+dh_search_set_search_string (DhSearch *search,
+ const gchar *str)
{
DhSearchPriv *priv;
gchar **split, **leftover, *lower;
@@ -744,7 +704,7 @@
g_return_if_fail (DH_IS_SEARCH (search));
- priv = search->priv;
+ priv = GET_PRIVATE (search);
priv->search_source = SEARCH_API;
@@ -836,7 +796,7 @@
g_return_if_fail (DH_IS_SEARCH (search));
- priv = search->priv;
+ priv = GET_PRIVATE (search);
gtk_widget_grab_focus (priv->entry);
}
Modified: trunk/src/dh-search.h
==============================================================================
--- trunk/src/dh-search.h (original)
+++ trunk/src/dh-search.h Thu Oct 2 19:29:53 2008
@@ -25,39 +25,33 @@
#include <gtk/gtk.h>
#include "dh-link.h"
-#define DH_SEARCH_ENTRY_OAFIID "OAFIID:GNOME_Dh_SearchEntry"
-#define DH_SEARCH_RESULT_OAFIID "OAFIID:GNOME_Dh_SearchResult"
+#define DH_TYPE_SEARCH (dh_search_get_type ())
+#define DH_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SEARCH, DhSearch))
+#define DH_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SEARCH, DhSearchClass))
+#define DH_IS_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SEARCH))
+#define DH_IS_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SEARCH))
-#define DH_TYPE_SEARCH (dh_search_get_type ())
-#define DH_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SEARCH, DhSearch))
-#define DH_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SEARCH, DhSearchClass))
-#define DH_IS_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SEARCH))
-#define DH_IS_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SEARCH))
-
-typedef struct _DhSearch DhSearch;
-typedef struct _DhSearchClass DhSearchClass;
-typedef struct _DhSearchPriv DhSearchPriv;
+typedef struct _DhSearch DhSearch;
+typedef struct _DhSearchClass DhSearchClass;
struct _DhSearch {
- GtkVBox parent;
-
- DhSearchPriv *priv;
+ GtkVBox parent_instance;
};
struct _DhSearchClass {
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
/* Signals */
void (*link_selected) (DhSearch *search,
- DhLink *link);
+ DhLink *link);
};
GType dh_search_get_type (void);
GtkWidget *dh_search_new (GList *keywords);
void dh_search_set_search_string (DhSearch *search,
- const gchar *str);
+ const gchar *str);
void dh_search_grab_focus (DhSearch *search);
void dh_search_show_advanced_options (DhSearch *search,
- gboolean show);
+ gboolean show);
#endif /* __DH_SEARCH_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]