gdm r5706 - in trunk: . gui/simple-greeter



Author: halfline
Date: Thu Feb  7 01:37:07 2008
New Revision: 5706
URL: http://svn.gnome.org/viewvc/gdm?rev=5706&view=rev

Log:
2008-02-06  Ray Strode  <rstrode redhat com>

	* gui/simple-greeter/gdm-session-option-widget.[ch]:
	Add the start of a session option widget for the panel


Added:
   trunk/gui/simple-greeter/gdm-session-option-widget.c
   trunk/gui/simple-greeter/gdm-session-option-widget.h
Modified:
   trunk/ChangeLog

Added: trunk/gui/simple-greeter/gdm-session-option-widget.c
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-session-option-widget.c	Thu Feb  7 01:37:07 2008
@@ -0,0 +1,197 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2008 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 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.
+ *
+ * Written by: William Jon McCann <mccann jhu edu>
+ *             Ray Strode <rstrode redhat com>
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+
+#include "gdm-session-option-widget.h"
+#include "gdm-sessions.h"
+
+#define GDM_SESSION_OPTION_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SESSION_OPTION_WIDGET, GdmSessionOptionWidgetPrivate))
+
+struct GdmSessionOptionWidgetPrivate
+{
+        gpointer dummy;
+};
+
+enum {
+        PROP_0,
+};
+
+enum {
+        SESSION_ACTIVATED,
+        NUMBER_OF_SIGNALS
+};
+
+static guint signals [NUMBER_OF_SIGNALS] = { 0, };
+
+static void     gdm_session_option_widget_class_init  (GdmSessionOptionWidgetClass *klass);
+static void     gdm_session_option_widget_init        (GdmSessionOptionWidget      *session_option_widget);
+static void     gdm_session_option_widget_finalize    (GObject                     *object);
+
+G_DEFINE_TYPE (GdmSessionOptionWidget, gdm_session_option_widget, GDM_TYPE_OPTION_WIDGET)
+static void
+gdm_session_option_widget_activated (GdmOptionWidget *widget)
+{
+        char *active_item_id;
+
+        active_item_id = gdm_option_widget_get_active_item (GDM_OPTION_WIDGET (widget));
+        if (active_item_id == NULL) {
+                return;
+        }
+
+        g_signal_emit (G_OBJECT (widget), signals[SESSION_ACTIVATED], 0);
+}
+
+
+static void
+gdm_session_option_widget_class_init (GdmSessionOptionWidgetClass *klass)
+{
+        GObjectClass *object_class;
+        GdmOptionWidgetClass *option_widget_class;
+
+        object_class = G_OBJECT_CLASS (klass);
+        option_widget_class = GDM_OPTION_WIDGET_CLASS (klass);
+
+        object_class->finalize = gdm_session_option_widget_finalize;
+        option_widget_class->activated = gdm_session_option_widget_activated;
+
+        signals[SESSION_ACTIVATED] = g_signal_new ("session-activated",
+                                                   G_TYPE_FROM_CLASS (object_class),
+                                                   G_SIGNAL_RUN_FIRST,
+                                                   G_STRUCT_OFFSET (GdmSessionOptionWidgetClass, session_activated),
+                                                   NULL,
+                                                   NULL,
+                                                   g_cclosure_marshal_VOID__VOID,
+                                                   G_TYPE_NONE,
+                                                   0);
+
+        g_type_class_add_private (klass, sizeof (GdmSessionOptionWidgetPrivate));
+}
+
+static void
+add_available_sessions (GdmSessionOptionWidget *widget)
+{
+        char     **session_files;
+        int        i;
+        gboolean   default_is_set;
+
+        session_files = gdm_get_all_sessions ();
+
+        default_is_set = FALSE;
+
+        for (i = 0; session_files[i] != NULL; i++) {
+                char *name;
+                char *comment;
+
+                if (!gdm_get_details_for_session (session_files[i],
+                                                  &name, &comment)) {
+                        continue;
+                }
+
+                gdm_option_widget_add_item (GDM_OPTION_WIDGET (widget),
+                                            session_files[i], name, comment,
+                                            FALSE);
+
+                if (!default_is_set) {
+                        gdm_option_widget_set_active_item (GDM_OPTION_WIDGET (widget),
+                                                           session_files[i]);
+                        default_is_set = TRUE;
+                }
+
+                g_free (name);
+                g_free (comment);
+        }
+
+        g_strfreev (session_files);
+}
+
+static void
+gdm_session_option_widget_init (GdmSessionOptionWidget *widget)
+{
+        widget->priv = GDM_SESSION_OPTION_WIDGET_GET_PRIVATE (widget);
+
+        add_available_sessions (widget);
+}
+
+static void
+gdm_session_option_widget_finalize (GObject *object)
+{
+        GdmSessionOptionWidget *session_option_widget;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GDM_IS_SESSION_OPTION_WIDGET (object));
+
+        session_option_widget = GDM_SESSION_OPTION_WIDGET (object);
+
+        g_return_if_fail (session_option_widget->priv != NULL);
+
+        G_OBJECT_CLASS (gdm_session_option_widget_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gdm_session_option_widget_new (void)
+{
+        GObject *object;
+
+        object = g_object_new (GDM_TYPE_SESSION_OPTION_WIDGET,
+                               "label-text", _("_Sessions:"),
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
+
+char *
+gdm_session_option_widget_get_current_session (GdmSessionOptionWidget *widget)
+{
+        char *active_item_id;
+
+        active_item_id = gdm_option_widget_get_active_item (GDM_OPTION_WIDGET (widget));
+        if (active_item_id == NULL) {
+                return NULL;
+        }
+
+        return active_item_id;
+}
+
+void
+gdm_session_option_widget_set_current_session (GdmSessionOptionWidget *widget,
+                                               const char             *session)
+{
+        if (gdm_option_widget_lookup_item (GDM_OPTION_WIDGET (widget), session,
+                                            NULL, NULL, NULL)) {
+                gdm_option_widget_set_active_item (GDM_OPTION_WIDGET (widget), session);
+        }
+}

Added: trunk/gui/simple-greeter/gdm-session-option-widget.h
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-session-option-widget.h	Thu Feb  7 01:37:07 2008
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 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 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.
+ *
+ *  Written by: Ray Strode <rstrode redhat com>
+ */
+
+#ifndef __GDM_SESSION_OPTION_WIDGET_H
+#define __GDM_SESSION_OPTION_WIDGET_H
+
+#include <glib-object.h>
+
+#include "gdm-recent-option-widget.h"
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_SESSION_OPTION_WIDGET         (gdm_session_option_widget_get_type ())
+#define GDM_SESSION_OPTION_WIDGET(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_SESSION_OPTION_WIDGET, GdmSessionOptionWidget))
+#define GDM_SESSION_OPTION_WIDGET_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_SESSION_OPTION_WIDGET, GdmSessionOptionWidgetClass))
+#define GDM_IS_SESSION_OPTION_WIDGET(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_SESSION_OPTION_WIDGET))
+#define GDM_IS_SESSION_OPTION_WIDGET_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_SESSION_OPTION_WIDGET))
+#define GDM_SESSION_OPTION_WIDGET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SESSION_OPTION_WIDGET, GdmSessionOptionWidgetClass))
+
+typedef struct GdmSessionOptionWidgetPrivate GdmSessionOptionWidgetPrivate;
+
+typedef struct
+{
+        GdmOptionWidget                parent;
+        GdmSessionOptionWidgetPrivate *priv;
+} GdmSessionOptionWidget;
+
+typedef struct
+{
+        GdmOptionWidgetClass              parent_class;
+
+        void (* session_activated)        (GdmSessionOptionWidget *widget);
+} GdmSessionOptionWidgetClass;
+
+GType                  gdm_session_option_widget_get_type               (void);
+GtkWidget *            gdm_session_option_widget_new                    (void);
+
+char *                 gdm_session_option_widget_get_current_session    (GdmSessionOptionWidget *widget);
+void                   gdm_session_option_widget_set_current_session    (GdmSessionOptionWidget *widget,
+                                                                         const char             *session);
+
+
+
+#endif /* __GDM_SESSION_OPTION_WIDGET_H */



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