one more time...

This commit is contained in:
Ray Strode 2007-12-14 16:10:12 +00:00
parent 55adbcc523
commit ef091d44ad

View File

@ -1,24 +1,117 @@
From 675a2a355ef15825b5998adc89a69d0958a0e2c0 Mon Sep 17 00:00:00 2001 Since it takes a lot of code to deal with the whole model/view
From: Ray Strode <rstrode@redhat.com> split of a tree view, it's probably better to abstract that
Date: Thu, 13 Dec 2007 10:06:26 -0500 work out into one unified "chooser" widget.
Subject: [PATCH] Add new chooser widget
Since it takes a lot of code to deal with the whole model/view
split of a tree view, it's probably better to abstract that
work out into one unified "chooser" widget.
--- diff -up /dev/null gdm-2.21.2/gui/simple-greeter/gdm-chooser-widget.h
gui/simple-greeter/gdm-chooser-widget.c | 1607 +++++++++++++++++++++++++++++++ --- /dev/null 2007-12-14 09:23:43.274012708 -0500
gui/simple-greeter/gdm-chooser-widget.h | 102 ++ +++ gdm-2.21.2/gui/simple-greeter/gdm-chooser-widget.h 2007-12-14 11:07:47.000000000 -0500
2 files changed, 1709 insertions(+), 0 deletions(-) @@ -0,0 +1,102 @@
create mode 100644 gui/simple-greeter/gdm-chooser-widget.c +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
create mode 100644 gui/simple-greeter/gdm-chooser-widget.h + *
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
diff --git a/gui/simple-greeter/gdm-chooser-widget.c b/gui/simple-greeter/gdm-chooser-widget.c + * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
new file mode 100644 + *
index 0000000..64186a2 + * This program is free software; you can redistribute it and/or modify
--- /dev/null + * it under the terms of the GNU General Public License as published by
+++ b/gui/simple-greeter/gdm-chooser-widget.c + * the Free Software Foundation; either version 2 of the License, or
@@ -0,0 +1,1607 @@ + * (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.
+ *
+ */
+
+#ifndef __GDM_CHOOSER_WIDGET_H
+#define __GDM_CHOOSER_WIDGET_H
+
+#include <glib-object.h>
+#include <gtk/gtkalignment.h>
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_CHOOSER_WIDGET (gdm_chooser_widget_get_type ())
+#define GDM_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidget))
+#define GDM_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidgetClass))
+#define GDM_IS_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_CHOOSER_WIDGET))
+#define GDM_IS_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_CHOOSER_WIDGET))
+#define GDM_CHOOSER_WIDGET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidgetClass))
+
+typedef struct GdmChooserWidgetPrivate GdmChooserWidgetPrivate;
+
+typedef struct
+{
+ GtkAlignment parent;
+ GdmChooserWidgetPrivate *priv;
+} GdmChooserWidget;
+
+typedef struct
+{
+ GtkAlignmentClass parent_class;
+
+ void (* activated) (GdmChooserWidget *widget);
+ void (* deactivated) (GdmChooserWidget *widget);
+
+#ifdef BUILD_ALLOCATION_HACK
+ gulong size_negotiation_handler;
+#endif
+} GdmChooserWidgetClass;
+
+typedef enum {
+ GDM_CHOOSER_WIDGET_POSITION_TOP = 0,
+ GDM_CHOOSER_WIDGET_POSITION_BOTTOM,
+} GdmChooserWidgetPosition;
+
+GType gdm_chooser_widget_get_type (void);
+GtkWidget * gdm_chooser_widget_new (const char *unactive_label,
+ const char *active_label);
+
+void gdm_chooser_widget_add_item (GdmChooserWidget *widget,
+ const char *id,
+ GdkPixbuf *image,
+ const char *name,
+ const char *comment,
+ gboolean is_in_use,
+ gboolean keep_separate);
+
+void gdm_chooser_widget_remove_item (GdmChooserWidget *widget,
+ const char *id);
+
+gboolean gdm_chooser_widget_lookup_item (GdmChooserWidget *widget,
+ const char *id,
+ GdkPixbuf **image,
+ char **name,
+ char **comment,
+ gboolean *is_in_use,
+ gboolean *is_separate);
+
+char * gdm_chooser_widget_get_active_item (GdmChooserWidget *widget);
+void gdm_chooser_widget_set_active_item (GdmChooserWidget *widget,
+ const char *item);
+
+void gdm_chooser_widget_set_item_in_use (GdmChooserWidget *widget,
+ const char *id,
+ gboolean is_in_use);
+
+void gdm_chooser_widget_set_in_use_message (GdmChooserWidget *widget,
+ const char *message);
+
+void gdm_chooser_widget_set_separator_position (GdmChooserWidget *widget,
+ GdmChooserWidgetPosition position);
+void gdm_chooser_widget_set_hide_inactive_items (GdmChooserWidget *widget,
+ gboolean should_hide);
+G_END_DECLS
+
+#endif /* __GDM_CHOOSER_WIDGET_H */
diff -up /dev/null gdm-2.21.2/gui/simple-greeter/gdm-chooser-widget.c
--- /dev/null 2007-12-14 09:23:43.274012708 -0500
+++ gdm-2.21.2/gui/simple-greeter/gdm-chooser-widget.c 2007-12-14 11:08:42.000000000 -0500
@@ -0,0 +1,1608 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * + *
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com> + * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
@ -199,7 +292,7 @@ index 0000000..64186a2
+ if (gtk_tree_model_get_iter (model, iter, path)) { + if (gtk_tree_model_get_iter (model, iter, path)) {
+ gtk_tree_model_get (model, iter, + gtk_tree_model_get (model, iter,
+ CHOOSER_ID_COLUMN, &item_id, -1); + CHOOSER_ID_COLUMN, &item_id, -1);
+ } + };
+ gtk_tree_path_free (path); + gtk_tree_path_free (path);
+ +
+ return item_id; + return item_id;
@ -1543,7 +1636,6 @@ index 0000000..64186a2
+ gboolean *is_in_use, + gboolean *is_in_use,
+ gboolean *is_separate) + gboolean *is_separate)
+{ +{
+ GtkTreeModel *model;
+ GtkTreeIter iter; + GtkTreeIter iter;
+ char *active_item_id; + char *active_item_id;
+ +
@ -1628,111 +1720,3 @@ index 0000000..64186a2
+ gdm_chooser_widget_grow (widget); + gdm_chooser_widget_grow (widget);
+ } + }
+} +}
diff --git a/gui/simple-greeter/gdm-chooser-widget.h b/gui/simple-greeter/gdm-chooser-widget.h
new file mode 100644
index 0000000..9a5581f
--- /dev/null
+++ b/gui/simple-greeter/gdm-chooser-widget.h
@@ -0,0 +1,102 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
+ * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ *
+ * 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 2 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.
+ *
+ */
+
+#ifndef __GDM_CHOOSER_WIDGET_H
+#define __GDM_CHOOSER_WIDGET_H
+
+#include <glib-object.h>
+#include <gtk/gtkalignment.h>
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_CHOOSER_WIDGET (gdm_chooser_widget_get_type ())
+#define GDM_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidget))
+#define GDM_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidgetClass))
+#define GDM_IS_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_CHOOSER_WIDGET))
+#define GDM_IS_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_CHOOSER_WIDGET))
+#define GDM_CHOOSER_WIDGET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidgetClass))
+
+typedef struct GdmChooserWidgetPrivate GdmChooserWidgetPrivate;
+
+typedef struct
+{
+ GtkAlignment parent;
+ GdmChooserWidgetPrivate *priv;
+} GdmChooserWidget;
+
+typedef struct
+{
+ GtkAlignmentClass parent_class;
+
+ void (* activated) (GdmChooserWidget *widget);
+ void (* deactivated) (GdmChooserWidget *widget);
+
+#ifdef BUILD_ALLOCATION_HACK
+ gulong size_negotiation_handler;
+#endif
+} GdmChooserWidgetClass;
+
+typedef enum {
+ GDM_CHOOSER_WIDGET_POSITION_TOP = 0,
+ GDM_CHOOSER_WIDGET_POSITION_BOTTOM,
+} GdmChooserWidgetPosition;
+
+GType gdm_chooser_widget_get_type (void);
+GtkWidget * gdm_chooser_widget_new (const char *unactive_label,
+ const char *active_label);
+
+void gdm_chooser_widget_add_item (GdmChooserWidget *widget,
+ const char *id,
+ GdkPixbuf *image,
+ const char *name,
+ const char *comment,
+ gboolean is_in_use,
+ gboolean keep_separate);
+void gdm_chooser_widget_remove_item (GdmChooserWidget *widget,
+ const char *id);
+gboolean gdm_chooser_widget_lookup_item (GdmChooserWidget *widget,
+ const char *id,
+ GdkPixbuf **image,
+ char **name,
+ char **comment,
+ gboolean *is_in_use,
+ gboolean *is_separate);
+
+char * gdm_chooser_widget_get_active_item (GdmChooserWidget *widget);
+void gdm_chooser_widget_set_active_item (GdmChooserWidget *widget,
+ const char *item);
+
+void gdm_chooser_widget_set_item_in_use (GdmChooserWidget *widget,
+ const char *id,
+ gboolean is_in_use);
+
+void gdm_chooser_widget_set_in_use_message (GdmChooserWidget *widget,
+ const char *message);
+
+void gdm_chooser_widget_set_separator_position (GdmChooserWidget *widget,
+ GdmChooserWidgetPosition position);
+void gdm_chooser_widget_set_hide_inactive_items (GdmChooserWidget *widget,
+ gboolean should_hide);
+G_END_DECLS
+
+#endif /* __GDM_CHOOSER_WIDGET_H */
+
+