[gnome-control-center] user-accounts: Move UmEditableEntry to lib
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: Move UmEditableEntry to lib
- Date: Fri, 13 May 2011 12:45:50 +0000 (UTC)
commit ac5bc2da75a14bfc1abae5741dc1a6fe4cd542d2
Author: Bastien Nocera <hadess hadess net>
Date: Fri May 13 13:44:55 2011 +0100
user-accounts: Move UmEditableEntry to lib
So it can be reused in the printers panel.
Also see:
https://bugzilla.gnome.org/show_bug.cgi?id=649511
libgnome-control-center/Makefile.am | 2 +
.../cc-editable-entry.c | 114 ++++++++++----------
libgnome-control-center/cc-editable-entry.h | 72 ++++++++++++
panels/user-accounts/Makefile.am | 3 +-
panels/user-accounts/data/user-accounts-dialog.ui | 2 +-
panels/user-accounts/um-editable-entry.h | 72 ------------
panels/user-accounts/um-user-panel.c | 12 +-
7 files changed, 139 insertions(+), 138 deletions(-)
---
diff --git a/libgnome-control-center/Makefile.am b/libgnome-control-center/Makefile.am
index d44745a..2a50e48 100644
--- a/libgnome-control-center/Makefile.am
+++ b/libgnome-control-center/Makefile.am
@@ -26,6 +26,8 @@ libgnome_control_center_la_SOURCES = \
cc-shell.h \
gconf-property-editor.c \
gconf-property-editor.h \
+ cc-editable-entry.c \
+ cc-editable-entry.h \
$(NULL)
libgnome_control_center_la_LDFLAGS = \
diff --git a/panels/user-accounts/um-editable-entry.c b/libgnome-control-center/cc-editable-entry.c
similarity index 81%
rename from panels/user-accounts/um-editable-entry.c
rename to libgnome-control-center/cc-editable-entry.c
index 527877c..8c35f21 100644
--- a/panels/user-accounts/um-editable-entry.c
+++ b/libgnome-control-center/cc-editable-entry.c
@@ -20,11 +20,11 @@
*/
#include <gdk/gdkkeysyms.h>
-#include "um-editable-entry.h"
+#include "cc-editable-entry.h"
#define EMPTY_TEXT "\xe2\x80\x94"
-struct _UmEditableEntryPrivate {
+struct _CcEditableEntryPrivate {
GtkNotebook *notebook;
GtkLabel *label;
GtkButton *button;
@@ -40,7 +40,7 @@ struct _UmEditableEntryPrivate {
gboolean in_stop_editing;
};
-#define UM_EDITABLE_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UM_TYPE_EDITABLE_ENTRY, UmEditableEntryPrivate))
+#define CC_EDITABLE_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryPrivate))
enum {
PROP_0,
@@ -65,13 +65,13 @@ enum {
static guint signals [LAST_SIGNAL] = { 0, };
-G_DEFINE_TYPE (UmEditableEntry, um_editable_entry, GTK_TYPE_ALIGNMENT);
+G_DEFINE_TYPE (CcEditableEntry, cc_editable_entry, GTK_TYPE_ALIGNMENT);
void
-um_editable_entry_set_text (UmEditableEntry *e,
+cc_editable_entry_set_text (CcEditableEntry *e,
const gchar *text)
{
- UmEditableEntryPrivate *priv;
+ CcEditableEntryPrivate *priv;
gchar *tmp;
GtkWidget *label;
@@ -94,16 +94,16 @@ um_editable_entry_set_text (UmEditableEntry *e,
}
const gchar *
-um_editable_entry_get_text (UmEditableEntry *e)
+cc_editable_entry_get_text (CcEditableEntry *e)
{
return e->priv->text;
}
void
-um_editable_entry_set_editable (UmEditableEntry *e,
+cc_editable_entry_set_editable (CcEditableEntry *e,
gboolean editable)
{
- UmEditableEntryPrivate *priv;
+ CcEditableEntryPrivate *priv;
priv = e->priv;
@@ -117,16 +117,16 @@ um_editable_entry_set_editable (UmEditableEntry *e,
}
gboolean
-um_editable_entry_get_editable (UmEditableEntry *e)
+cc_editable_entry_get_editable (CcEditableEntry *e)
{
return e->priv->editable;
}
static void
update_entry_font (GtkWidget *widget,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
- UmEditableEntryPrivate *priv = e->priv;
+ CcEditableEntryPrivate *priv = e->priv;
PangoFontDescription *desc;
GtkStyleContext *style;
gint size;
@@ -156,13 +156,13 @@ update_entry_font (GtkWidget *widget,
}
static void
-update_fonts (UmEditableEntry *e)
+update_fonts (CcEditableEntry *e)
{
PangoAttrList *attrs;
PangoAttribute *attr;
GtkWidget *label;
- UmEditableEntryPrivate *priv = e->priv;
+ CcEditableEntryPrivate *priv = e->priv;
attrs = pango_attr_list_new ();
if (priv->scale_set) {
@@ -185,10 +185,10 @@ update_fonts (UmEditableEntry *e)
}
void
-um_editable_entry_set_weight (UmEditableEntry *e,
+cc_editable_entry_set_weight (CcEditableEntry *e,
gint weight)
{
- UmEditableEntryPrivate *priv = e->priv;
+ CcEditableEntryPrivate *priv = e->priv;
if (priv->weight == weight && priv->weight_set)
return;
@@ -203,16 +203,16 @@ um_editable_entry_set_weight (UmEditableEntry *e,
}
gint
-um_editable_entry_get_weight (UmEditableEntry *e)
+cc_editable_entry_get_weight (CcEditableEntry *e)
{
return e->priv->weight;
}
void
-um_editable_entry_set_scale (UmEditableEntry *e,
+cc_editable_entry_set_scale (CcEditableEntry *e,
gdouble scale)
{
- UmEditableEntryPrivate *priv = e->priv;
+ CcEditableEntryPrivate *priv = e->priv;
if (priv->scale == scale && priv->scale_set)
return;
@@ -227,34 +227,34 @@ um_editable_entry_set_scale (UmEditableEntry *e,
}
gdouble
-um_editable_entry_get_scale (UmEditableEntry *e)
+cc_editable_entry_get_scale (CcEditableEntry *e)
{
return e->priv->scale;
}
static void
-um_editable_entry_set_property (GObject *object,
+cc_editable_entry_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- UmEditableEntry *e = UM_EDITABLE_ENTRY (object);
+ CcEditableEntry *e = CC_EDITABLE_ENTRY (object);
switch (prop_id) {
case PROP_TEXT:
- um_editable_entry_set_text (e, g_value_get_string (value));
+ cc_editable_entry_set_text (e, g_value_get_string (value));
break;
case PROP_EDITABLE:
- um_editable_entry_set_editable (e, g_value_get_boolean (value));
+ cc_editable_entry_set_editable (e, g_value_get_boolean (value));
break;
case PROP_WEIGHT:
- um_editable_entry_set_weight (e, g_value_get_int (value));
+ cc_editable_entry_set_weight (e, g_value_get_int (value));
break;
case PROP_WEIGHT_SET:
e->priv->weight_set = g_value_get_boolean (value);
break;
case PROP_SCALE:
- um_editable_entry_set_scale (e, g_value_get_double (value));
+ cc_editable_entry_set_scale (e, g_value_get_double (value));
break;
case PROP_SCALE_SET:
e->priv->scale_set = g_value_get_boolean (value);
@@ -266,32 +266,32 @@ um_editable_entry_set_property (GObject *object,
}
static void
-um_editable_entry_get_property (GObject *object,
+cc_editable_entry_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- UmEditableEntry *e = UM_EDITABLE_ENTRY (object);
+ CcEditableEntry *e = CC_EDITABLE_ENTRY (object);
switch (prop_id) {
case PROP_TEXT:
g_value_set_string (value,
- um_editable_entry_get_text (e));
+ cc_editable_entry_get_text (e));
break;
case PROP_EDITABLE:
g_value_set_boolean (value,
- um_editable_entry_get_editable (e));
+ cc_editable_entry_get_editable (e));
break;
case PROP_WEIGHT:
g_value_set_int (value,
- um_editable_entry_get_weight (e));
+ cc_editable_entry_get_weight (e));
break;
case PROP_WEIGHT_SET:
g_value_set_boolean (value, e->priv->weight_set);
break;
case PROP_SCALE:
g_value_set_double (value,
- um_editable_entry_get_scale (e));
+ cc_editable_entry_get_scale (e));
break;
case PROP_SCALE_SET:
g_value_set_boolean (value, e->priv->scale_set);
@@ -303,31 +303,31 @@ um_editable_entry_get_property (GObject *object,
}
static void
-um_editable_entry_finalize (GObject *object)
+cc_editable_entry_finalize (GObject *object)
{
- UmEditableEntry *e = (UmEditableEntry*)object;
+ CcEditableEntry *e = (CcEditableEntry*)object;
g_free (e->priv->text);
- G_OBJECT_CLASS (um_editable_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (cc_editable_entry_parent_class)->finalize (object);
}
static void
-um_editable_entry_class_init (UmEditableEntryClass *class)
+cc_editable_entry_class_init (CcEditableEntryClass *class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
- object_class->set_property = um_editable_entry_set_property;
- object_class->get_property = um_editable_entry_get_property;
- object_class->finalize = um_editable_entry_finalize;
+ object_class->set_property = cc_editable_entry_set_property;
+ object_class->get_property = cc_editable_entry_get_property;
+ object_class->finalize = cc_editable_entry_finalize;
signals[EDITING_DONE] =
g_signal_new ("editing-done",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (UmEditableEntryClass, editing_done),
+ G_STRUCT_OFFSET (CcEditableEntryClass, editing_done),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -368,17 +368,17 @@ um_editable_entry_class_init (UmEditableEntryClass *class)
FALSE,
G_PARAM_READWRITE));
- g_type_class_add_private (class, sizeof (UmEditableEntryPrivate));
+ g_type_class_add_private (class, sizeof (CcEditableEntryPrivate));
}
static void
-start_editing (UmEditableEntry *e)
+start_editing (CcEditableEntry *e)
{
gtk_notebook_set_current_page (e->priv->notebook, PAGE_ENTRY);
}
static void
-stop_editing (UmEditableEntry *e)
+stop_editing (CcEditableEntry *e)
{
/* Avoid launching another "editing-done" signal
* caused by the notebook page change */
@@ -387,28 +387,28 @@ stop_editing (UmEditableEntry *e)
e->priv->in_stop_editing = TRUE;
gtk_notebook_set_current_page (e->priv->notebook, PAGE_BUTTON);
- um_editable_entry_set_text (e, gtk_entry_get_text (e->priv->entry));
+ cc_editable_entry_set_text (e, gtk_entry_get_text (e->priv->entry));
g_signal_emit (e, signals[EDITING_DONE], 0);
e->priv->in_stop_editing = FALSE;
}
static void
-cancel_editing (UmEditableEntry *e)
+cancel_editing (CcEditableEntry *e)
{
- gtk_entry_set_text (e->priv->entry, um_editable_entry_get_text (e));
+ gtk_entry_set_text (e->priv->entry, cc_editable_entry_get_text (e));
gtk_notebook_set_current_page (e->priv->notebook, PAGE_BUTTON);
}
static void
button_clicked (GtkWidget *widget,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
start_editing (e);
}
static void
entry_activated (GtkWidget *widget,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
stop_editing (e);
}
@@ -416,7 +416,7 @@ entry_activated (GtkWidget *widget,
static gboolean
entry_focus_out (GtkWidget *widget,
GdkEventFocus *event,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
stop_editing (e);
return FALSE;
@@ -425,7 +425,7 @@ entry_focus_out (GtkWidget *widget,
static gboolean
entry_key_press (GtkWidget *widget,
GdkEventKey *event,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
if (event->keyval == GDK_KEY_Escape) {
cancel_editing (e);
@@ -436,9 +436,9 @@ entry_key_press (GtkWidget *widget,
static void
update_button_padding (GtkWidget *widget,
GtkAllocation *allocation,
- UmEditableEntry *e)
+ CcEditableEntry *e)
{
- UmEditableEntryPrivate *priv = e->priv;
+ CcEditableEntryPrivate *priv = e->priv;
GtkAllocation alloc;
gint offset;
gint pad;
@@ -453,11 +453,11 @@ update_button_padding (GtkWidget *widget,
}
static void
-um_editable_entry_init (UmEditableEntry *e)
+cc_editable_entry_init (CcEditableEntry *e)
{
- UmEditableEntryPrivate *priv;
+ CcEditableEntryPrivate *priv;
- priv = e->priv = UM_EDITABLE_ENTRY_GET_PRIVATE (e);
+ priv = e->priv = CC_EDITABLE_ENTRY_GET_PRIVATE (e);
priv->weight = PANGO_WEIGHT_NORMAL;
priv->weight_set = FALSE;
@@ -502,7 +502,7 @@ um_editable_entry_init (UmEditableEntry *e)
}
GtkWidget *
-um_editable_entry_new (void)
+cc_editable_entry_new (void)
{
- return (GtkWidget *) g_object_new (UM_TYPE_EDITABLE_ENTRY, NULL);
+ return (GtkWidget *) g_object_new (CC_TYPE_EDITABLE_ENTRY, NULL);
}
diff --git a/libgnome-control-center/cc-editable-entry.h b/libgnome-control-center/cc-editable-entry.h
new file mode 100644
index 0000000..2906d61
--- /dev/null
+++ b/libgnome-control-center/cc-editable-entry.h
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright 2009-2010 Red Hat, Inc,
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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, Boston, MA 02111-1307, USA.
+ *
+ * Written by: Matthias Clasen <mclasen redhat com>
+ */
+
+#ifndef _CC_EDITABLE_ENTRY_H_
+#define _CC_EDITABLE_ENTRY_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_EDITABLE_ENTRY cc_editable_entry_get_type()
+
+#define CC_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntry))
+#define CC_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryClass))
+#define CC_IS_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_EDITABLE_ENTRY))
+#define CC_IS_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_EDITABLE_ENTRY))
+#define CC_EDITABLE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryClass))
+
+typedef struct _CcEditableEntry CcEditableEntry;
+typedef struct _CcEditableEntryClass CcEditableEntryClass;
+typedef struct _CcEditableEntryPrivate CcEditableEntryPrivate;
+
+struct _CcEditableEntry
+{
+ GtkAlignment parent;
+
+ CcEditableEntryPrivate *priv;
+};
+
+struct _CcEditableEntryClass
+{
+ GtkAlignmentClass parent_class;
+
+ void (* editing_done) (CcEditableEntry *entry);
+};
+
+GType cc_editable_entry_get_type (void) G_GNUC_CONST;
+GtkWidget *cc_editable_entry_new (void);
+void cc_editable_entry_set_text (CcEditableEntry *entry,
+ const gchar *text);
+const gchar *cc_editable_entry_get_text (CcEditableEntry *entry);
+void cc_editable_entry_set_editable (CcEditableEntry *entry,
+ gboolean editable);
+gboolean cc_editable_entry_get_editable (CcEditableEntry *entry);
+void cc_editable_entry_set_weight (CcEditableEntry *entry,
+ gint weight);
+gint cc_editable_entry_get_weight (CcEditableEntry *entry);
+void cc_editable_entry_set_scale (CcEditableEntry *entry,
+ gdouble scale);
+gdouble cc_editable_entry_get_scale (CcEditableEntry *entry);
+
+G_END_DECLS
+
+#endif /* _CC_EDITABLE_ENTRY_H_ */
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index c53bc25..6bc4f39 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DUM_PIXMAP_DIR=\""$(pkgdatadir)/pixmaps"\" \
-I$(srcdir)/../common/ \
+ -I$(top_srcdir)/libgnome-control-center/ \
$(PANEL_CFLAGS) \
$(USER_ACCOUNTS_PANEL_CFLAGS) \
$(DISABLE_DEPRECATED)
@@ -59,8 +60,6 @@ libuser_accounts_la_SOURCES = \
$(MARSHALFILES) \
um-editable-button.h \
um-editable-button.c \
- um-editable-entry.h \
- um-editable-entry.c \
um-editable-combo.h \
um-editable-combo.c \
um-user-panel.h \
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui b/panels/user-accounts/data/user-accounts-dialog.ui
index 15c0a9e..ba3f72a 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -204,7 +204,7 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="UmEditableEntry" id="full-name-entry">
+ <object class="CcEditableEntry" id="full-name-entry">
<property name="visible">True</property>
<property name="scale">1.2</property>
<property name="weight">700</property>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index d431ec8..7fe45ed 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -45,7 +45,7 @@
#include "um-strength-bar.h"
#include "um-editable-button.h"
-#include "um-editable-entry.h"
+#include "cc-editable-entry.h"
#include "um-editable-combo.h"
#include "um-account-dialog.h"
@@ -569,7 +569,7 @@ show_user (UmUser *user, UmUserPanelPrivate *d)
um_photo_dialog_set_user (d->photo_dialog, user);
widget = get_widget (d, "full-name-entry");
- um_editable_entry_set_text (UM_EDITABLE_ENTRY (widget), um_user_get_real_name (user));
+ cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), um_user_get_real_name (user));
gtk_widget_set_tooltip_text (widget, um_user_get_user_name (user));
widget = get_widget (d, "account-type-combo");
@@ -636,7 +636,7 @@ change_name_done (GtkWidget *entry,
user = get_selected_user (d);
- text = um_editable_entry_get_text (UM_EDITABLE_ENTRY (entry));
+ text = cc_editable_entry_get_text (CC_EDITABLE_ENTRY (entry));
if (g_strcmp0 (text, um_user_get_real_name (user)) != 0) {
um_user_set_real_name (user, text);
@@ -956,7 +956,7 @@ on_permission_changed (GPermission *permission,
gtk_widget_show (get_widget (d, "user-icon-button"));
gtk_widget_hide (get_widget (d, "user-icon-nonbutton"));
- um_editable_entry_set_editable (UM_EDITABLE_ENTRY (get_widget (d, "full-name-entry")), TRUE);
+ cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (get_widget (d, "full-name-entry")), TRUE);
remove_unlock_tooltip (get_widget (d, "full-name-entry"));
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), TRUE);
@@ -971,7 +971,7 @@ on_permission_changed (GPermission *permission,
gtk_widget_hide (get_widget (d, "user-icon-button"));
gtk_widget_show (get_widget (d, "user-icon-nonbutton"));
- um_editable_entry_set_editable (UM_EDITABLE_ENTRY (get_widget (d, "full-name-entry")), FALSE);
+ cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (get_widget (d, "full-name-entry")), FALSE);
add_unlock_tooltip (get_widget (d, "full-name-entry"));
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), FALSE);
@@ -1240,7 +1240,7 @@ um_user_panel_init (UmUserPanel *self)
/* register types that the builder might need */
type = um_strength_bar_get_type ();
type = um_editable_button_get_type ();
- type = um_editable_entry_get_type ();
+ type = cc_editable_entry_get_type ();
type = um_editable_combo_get_type ();
gtk_widget_set_size_request (GTK_WIDGET (self), -1, 350);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]