~timchen119/ubuntu/trusty/gnome-bluetooth/lp1035431

« back to all changes in this revision

Viewing changes to moblin/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-01-07 15:13:11 UTC
  • mto: (2.2.1 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 31.
  • Revision ID: james.westby@ubuntu.com-20100107151311-vp5pnkrksrlfxnj4
Tags: upstream-2.29.3
ImportĀ upstreamĀ versionĀ 2.29.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *  BlueZ - Bluetooth protocol stack for Linux
 
4
 *
 
5
 *  Copyright (C) 2009, Intel Corporation.
 
6
 *
 
7
 *  This library is free software; you can redistribute it and/or
 
8
 *  modify it under the terms of the GNU Lesser General Public
 
9
 *  License as published by the Free Software Foundation; either
 
10
 *  version 2.1 of the License, or (at your option) any later version.
 
11
 *
 
12
 *  This library is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 *  Lesser General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU Lesser General Public
 
18
 *  License along with this library; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 *
 
21
 *  Written by: Joshua Lock <josh@linux.intel.com>
 
22
 *
 
23
 */
 
24
 
 
25
#ifdef HAVE_CONFIG_H
 
26
#include <config.h>
 
27
#endif
 
28
 
 
29
#include <gtk/gtk.h>
 
30
#include <gdk/gdkx.h>
 
31
#include <glib/gi18n.h>
 
32
#include <nbtk/nbtk-gtk.h>
 
33
#include <moblin-panel/mpl-panel-common.h>
 
34
#include <moblin-panel/mpl-panel-gtk.h>
 
35
#include <bluetooth-enums.h>
 
36
 
 
37
#include "moblin-panel.h"
 
38
 
 
39
#define PKGTHEMEDIR PKGDATADIR"/theme"
 
40
 
 
41
static void
 
42
bluetooth_status_changed (MoblinPanel *panel, gboolean connecting, gpointer user_data)
 
43
{
 
44
        MplPanelClient *client = MPL_PANEL_CLIENT (user_data);
 
45
        gchar *style = NULL;
 
46
 
 
47
        if (connecting) {
 
48
                style = g_strdup ("state-connecting");
 
49
        } else {
 
50
                style = g_strdup ("state-idle");
 
51
        }
 
52
 
 
53
        mpl_panel_client_request_button_style (client, style);
 
54
        g_free (style);
 
55
}
 
56
 
 
57
static void
 
58
panel_request_focus (MoblinPanel *panel, gpointer user_data)
 
59
{
 
60
        MplPanelClient *client = MPL_PANEL_CLIENT (user_data);
 
61
 
 
62
        mpl_panel_client_request_focus (client);
 
63
}
 
64
 
 
65
/*
 
66
 * When the panel is hidden we should re-set the MoblinPanel to its default state.
 
67
 * i.e. stop any discovery and show the defaults devices view
 
68
 */
 
69
static void
 
70
_reset_view_cb (MplPanelClient *client, gpointer user_data)
 
71
{
 
72
        MoblinPanel *panel = MOBLIN_PANEL (user_data);
 
73
 
 
74
        moblin_panel_reset_view (panel);
 
75
}
 
76
 
 
77
int
 
78
main (int argc, char *argv[])
 
79
{
 
80
        MplPanelClient *panel;
 
81
        GtkWidget      *window, *content;
 
82
        GtkRequisition  req;
 
83
        gboolean        standalone = FALSE;
 
84
        GtkSettings    *settings;
 
85
        GError         *error = NULL;
 
86
        GOptionEntry    entries[] = {
 
87
                { "standalone", 's', 0, G_OPTION_ARG_NONE, &standalone,
 
88
                _("Run in standalone mode"), NULL },
 
89
                { NULL }
 
90
        };
 
91
 
 
92
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 
93
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
94
        textdomain (GETTEXT_PACKAGE);
 
95
 
 
96
        g_set_application_name (_("Moblin Bluetooth Panel"));
 
97
        gtk_init_with_args (&argc, &argv, _("- Moblin Bluetooth Panel"),
 
98
                                entries, GETTEXT_PACKAGE, &error);
 
99
 
 
100
        if (error) {
 
101
                g_printerr ("%s\n", error->message);
 
102
                g_error_free (error);
 
103
                return 1;
 
104
        }
 
105
 
 
106
        gtk_window_set_default_icon_name ("bluetooth");
 
107
 
 
108
        /* Force to correct theme */
 
109
        settings = gtk_settings_get_default ();
 
110
        gtk_settings_set_string_property (settings, "gtk-theme-name",
 
111
                                        "Moblin-Netbook", NULL);
 
112
 
 
113
        if (standalone) {
 
114
                window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
115
                g_signal_connect (window, "delete-event", (GCallback) gtk_main_quit,
 
116
                                NULL);
 
117
                gtk_widget_set_size_request (window, 1000, -1);
 
118
                content = moblin_panel_new ();
 
119
                gtk_widget_show (content);
 
120
 
 
121
                gtk_container_add (GTK_CONTAINER (window), content);
 
122
                gtk_widget_show (window);
 
123
        }  else {
 
124
                panel = mpl_panel_gtk_new (MPL_PANEL_BLUETOOTH, _("bluetooth"),
 
125
                                        PKGTHEMEDIR "/bluetooth-panel.css",
 
126
                                        "state-idle", TRUE);
 
127
                window  = mpl_panel_gtk_get_window (MPL_PANEL_GTK (panel));
 
128
 
 
129
                content = moblin_panel_new ();
 
130
                g_signal_connect (panel, "hide-end", (GCallback) _reset_view_cb, content);
 
131
                g_signal_connect (content, "state-changed",
 
132
                                G_CALLBACK (bluetooth_status_changed), panel);
 
133
                g_signal_connect (content, "request-focus",
 
134
                                  G_CALLBACK (panel_request_focus), panel);
 
135
                gtk_widget_show (content);
 
136
 
 
137
                gtk_container_add (GTK_CONTAINER (window), content);
 
138
                gtk_widget_show (window);
 
139
                gtk_widget_size_request (window, &req);
 
140
                mpl_panel_client_set_height_request (panel, req.height);
 
141
        }
 
142
 
 
143
        gtk_main ();
 
144
 
 
145
        return 0;
 
146
}