~ubuntu-branches/ubuntu/raring/gnome-bluetooth/raring-proposed

« back to all changes in this revision

Viewing changes to wizard/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort, Laurent Bigonville, Emilio Pozuelo Monfort
  • Date: 2011-02-27 15:45:22 UTC
  • mfrom: (1.4.1 upstream) (2.1.11 sid)
  • mto: (2.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: james.westby@ubuntu.com-20110227154522-p2nrmq4sxbrl3j4b
Tags: 2.91.5-1
[ Laurent Bigonville ]
* New upstream release
  - Bump libgnome-bluetooth soname
  - Update .symbols file
  - Japanese translation updated (Closes: #601518)
* debian/control.in:
  - Bump build-dependencies
  - Drop not needed build-dependencies
  - Add libgnome-control-center-dev build-dependency
  - Add gobject-introspection, libgirepository1.0-dev, gir1.2-atk-1.0,
    gir1.2-freedesktop, gir1.2-gtk-3.0 and libatk1.0-dev for introspection
  - Bump Standards-Version to 3.9.1 (no further changes)
  - Bump debhelper compatibility to 8
  - Remove duplicate Section to please lintian
  - Make gnome-bluetooth depends against ${gir:Depends} and libdconf0
  - Add gir1.2-gnomebluetooth-1.0 package
* Switch to dpkg-source 3.0 (quilt) format
* debian/libgnome-bluetooth-dev.install: Install .gir file
* debian/rules:
  - Add --enable-introspection
  - Add parameters for dh_girepository for gnome-bluetooth package
* debian/gnome-bluetooth.install:
  - Remove debian/tmp/etc
  - Add debian/tmp/usr/lib/control-center-1/panels/*.so,
    debian/tmp/usr/lib/gnome-bluetooth/*.so*,
    debian/tmp/usr/lib/gnome-bluetooth/*.typelib,
    debian/tmp/usr/share/GConf/gsettings/,
    debian/tmp/usr/share/glib-2.0/schemas/

[ Emilio Pozuelo Monfort ]
* debian/control.in:
  + Bump gobject-introspection build dependency to get a
    dh_girepository that can cope with private libraries.
  + Update gtk+ 3 package names.
* New upstream release.
* debian/rules:
  + Don't run dh_makeshlibs on gnome-bluetooth.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <gdk/gdkkeysyms.h>
32
32
 
33
33
#include <dbus/dbus-glib.h>
34
 
#include <unique/uniqueapp.h>
35
34
 
36
 
#include <bling-spinner.h>
37
35
#include <bluetooth-client.h>
38
36
#include <bluetooth-client-private.h>
39
37
#include <bluetooth-chooser.h>
83
81
static GtkBuilder *builder = NULL;
84
82
 
85
83
static GtkAssistant *window_assistant = NULL;
 
84
static GtkWidget *button_close = NULL;
 
85
static GtkWidget *button_cancel = NULL;
86
86
static GtkWidget *page_search = NULL;
87
87
static GtkWidget *page_connecting = NULL;
88
88
static GtkWidget *page_setup = NULL;
117
117
static GtkWidget *radio_0000 = NULL;
118
118
static GtkWidget *radio_1111 = NULL;
119
119
static GtkWidget *radio_1234 = NULL;
 
120
static GtkWidget *radio_none = NULL;
120
121
static GtkWidget *radio_custom = NULL;
121
122
static GtkWidget *entry_custom = NULL;
122
123
 
411
412
        gtk_main_quit();
412
413
}
413
414
 
414
 
/* HACK, to access the GtkAssistant buttons */
415
 
struct RealGtkAssistant
416
 
{
417
 
        GtkWindow  parent;
418
 
 
419
 
        GtkWidget *cancel;
420
 
        GtkWidget *forward;
421
 
        GtkWidget *back;
422
 
        GtkWidget *apply;
423
 
        GtkWidget *close;
424
 
        GtkWidget *last;
425
 
 
426
 
        /*< private >*/
427
 
        GtkAssistantPrivate *priv;
428
 
};
429
 
typedef struct RealGtkAssistant RealGtkAssistant;
430
 
 
431
 
static gboolean
432
 
prepare_idle_cb (gpointer data)
433
 
{
434
 
        RealGtkAssistant *assistant = (RealGtkAssistant *) window_assistant;
435
 
        gint page;
436
 
 
437
 
        page = gtk_assistant_get_current_page (GTK_ASSISTANT (window_assistant));
438
 
        if (page == PAGE_FAILURE) {
439
 
                gtk_widget_hide (assistant->cancel);
440
 
                gtk_widget_hide (assistant->forward);
441
 
                gtk_widget_hide (assistant->back);
442
 
                gtk_widget_hide (assistant->apply);
443
 
                gtk_widget_hide (assistant->last);
444
 
                gtk_widget_show (assistant->close);
445
 
                gtk_widget_set_sensitive (assistant->close, TRUE);
446
 
        }
447
 
        if (page == PAGE_CONNECTING) {
448
 
                gtk_widget_hide (assistant->forward);
449
 
                gtk_widget_hide (assistant->back);
450
 
                gtk_widget_hide (assistant->apply);
451
 
                gtk_widget_hide (assistant->last);
452
 
                gtk_widget_hide (assistant->close);
453
 
                gtk_widget_show (assistant->cancel);
454
 
                gtk_widget_set_sensitive (assistant->cancel, TRUE);
455
 
        }
456
 
        if (page == PAGE_SETUP) {
457
 
                gtk_widget_hide (assistant->forward);
458
 
                gtk_widget_hide (assistant->back);
459
 
                gtk_widget_hide (assistant->apply);
460
 
                gtk_widget_hide (assistant->last);
461
 
                gtk_widget_hide (assistant->close);
462
 
                gtk_widget_show (assistant->cancel);
463
 
                gtk_widget_set_sensitive (assistant->cancel, TRUE);
464
 
        }
465
 
        if (page == PAGE_SSP_SETUP) {
466
 
                gtk_widget_hide (assistant->forward);
467
 
                gtk_widget_hide (assistant->back);
468
 
                gtk_widget_hide (assistant->apply);
469
 
                gtk_widget_hide (assistant->last);
470
 
                gtk_widget_hide (assistant->close);
471
 
                if (display_called == FALSE) {
472
 
                        gtk_widget_hide (assistant->cancel);
473
 
                } else {
474
 
                        gtk_widget_show (assistant->cancel);
475
 
                        gtk_widget_set_sensitive (assistant->cancel, TRUE);
476
 
                }
477
 
        }
478
 
        if (page == PAGE_FINISHING) {
479
 
                gtk_widget_hide (assistant->forward);
480
 
                gtk_widget_hide (assistant->back);
481
 
                gtk_widget_hide (assistant->apply);
482
 
                gtk_widget_hide (assistant->last);
483
 
                gtk_widget_hide (assistant->cancel);
484
 
                gtk_widget_show (assistant->close);
485
 
                gtk_widget_set_sensitive (assistant->close, FALSE);
486
 
        }
487
 
        return FALSE;
488
 
}
489
 
 
490
415
void prepare_callback (GtkWidget *assistant,
491
416
                       GtkWidget *page,
492
417
                       gpointer data)
493
418
{
494
419
        gboolean complete = TRUE;
495
420
 
 
421
        gtk_widget_hide (button_close);
 
422
        gtk_widget_hide (button_cancel);
 
423
 
496
424
        if (page == page_search) {
497
425
                complete = set_page_search_complete ();
498
426
                bluetooth_chooser_start_discovery(selector);
505
433
 
506
434
                complete = FALSE;
507
435
 
508
 
                bling_spinner_start (BLING_SPINNER (spinner_connecting));
 
436
                gtk_spinner_start (GTK_SPINNER (spinner_connecting));
509
437
 
510
438
                /* translators:
511
439
                 * The '%s' is the device name, for example:
512
 
                 * Connecting to 'Sony Bluetooth Headset' now...
 
440
                 * Connecting to 'Sony Bluetooth Headset'...
513
441
                 */
514
442
                text = g_strdup_printf (_("Connecting to '%s'..."), target_name);
515
443
                gtk_label_set_text (GTK_LABEL (label_connecting), text);
516
444
                g_free (text);
 
445
 
 
446
                gtk_widget_show (button_cancel);
517
447
        } else {
518
 
                bling_spinner_stop (BLING_SPINNER (spinner_connecting));
 
448
                gtk_spinner_stop (GTK_SPINNER (spinner_connecting));
519
449
        }
520
450
 
521
451
        if ((page == page_setup || page == page_connecting) && (create_started == FALSE)) {
557
487
                } else {
558
488
                        g_assert_not_reached ();
559
489
                }
 
490
 
 
491
                gtk_widget_show (button_cancel);
560
492
        }
561
493
 
562
494
        if (page == page_finishing) {
564
496
 
565
497
                complete = FALSE;
566
498
 
567
 
                bling_spinner_start (BLING_SPINNER (spinner_finishing));
 
499
                gtk_spinner_start (GTK_SPINNER (spinner_finishing));
568
500
 
569
501
                /* translators:
570
502
                 * The '%s' is the device name, for example:
573
505
                text = g_strdup_printf (_("Please wait while finishing setup on device '%s'..."), target_name);
574
506
                gtk_label_set_text (GTK_LABEL (label_finishing), text);
575
507
                g_free (text);
 
508
 
 
509
                gtk_widget_show (button_close);
576
510
        } else {
577
 
                bling_spinner_stop (BLING_SPINNER (spinner_finishing));
 
511
                gtk_spinner_stop (GTK_SPINNER (spinner_finishing));
578
512
        }
579
513
 
580
514
        if (page == page_summary) {
617
551
        if (page == page_failure) {
618
552
                complete = FALSE;
619
553
                gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), W("restart_button"));
 
554
                gtk_widget_show (button_close);
620
555
        } else {
621
556
                if (gtk_widget_get_parent (W("restart_button")) != NULL)
622
557
                        gtk_assistant_remove_action_widget (GTK_ASSISTANT (assistant), W("restart_button"));
623
558
        }
624
559
 
625
 
        if (page == page_ssp_setup && display_called == FALSE) {
626
 
                complete = FALSE;
627
 
                gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), W("matches_button"));
628
 
                gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), W("does_not_match_button"));
 
560
        if (page == page_ssp_setup) {
 
561
                if (display_called == FALSE) {
 
562
                        complete = FALSE;
 
563
                        gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), W("matches_button"));
 
564
                        gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), W("does_not_match_button"));
 
565
                } else {
 
566
                        gtk_widget_show (button_cancel);
 
567
                }
629
568
        } else {
630
569
                if (gtk_widget_get_parent (W("does_not_match_button")) != NULL)
631
570
                        gtk_assistant_remove_action_widget (GTK_ASSISTANT (assistant), W("does_not_match_button"));
635
574
 
636
575
        gtk_assistant_set_page_complete (GTK_ASSISTANT(assistant),
637
576
                                         page, complete);
638
 
 
639
 
        /* HACK to allow hiding/showing the buttons
640
 
         * instead of relying on the GtkAssistant doing that
641
 
         * for us */
642
 
        g_idle_add (prepare_idle_cb, NULL);
643
577
}
644
578
 
645
579
static gboolean
673
607
        if (event->length == 0)
674
608
                return FALSE;
675
609
 
676
 
        if ((event->keyval >= GDK_0 && event->keyval <= GDK_9) ||
677
 
            (event->keyval >= GDK_KP_0 && event->keyval <= GDK_KP_9))
 
610
        if ((event->keyval >= GDK_KEY_0 && event->keyval <= GDK_KEY_9) ||
 
611
            (event->keyval >= GDK_KEY_KP_0 && event->keyval <= GDK_KEY_KP_9))
678
612
                return FALSE;
679
613
 
680
614
        return TRUE;
894
828
 
895
829
        gtk_assistant_set_forward_page_func (assistant, page_func, NULL, NULL);
896
830
 
 
831
        /* The 2 custom buttons */
 
832
        button_close = W("close_button");
 
833
        button_cancel = W("cancel_button");
 
834
        gtk_assistant_add_action_widget (assistant, button_close);
 
835
        gtk_assistant_add_action_widget (assistant, button_cancel);
 
836
        gtk_widget_hide (button_close);
 
837
        gtk_widget_hide (button_cancel);
 
838
 
897
839
        /* Intro page */
898
840
        combo = gtk_combo_box_new();
899
841
 
965
907
        radio_0000 = W("radio_0000");
966
908
        radio_1111 = W("radio_1111");
967
909
        radio_1234 = W("radio_1234");
 
910
        radio_none = W("radio_none");
968
911
        radio_custom = W("radio_custom");
969
912
        entry_custom = W("entry_custom");
970
913
 
972
915
        g_object_set_data (G_OBJECT (radio_0000), "pin", "0000");
973
916
        g_object_set_data (G_OBJECT (radio_1111), "pin", "1111");
974
917
        g_object_set_data (G_OBJECT (radio_1234), "pin", "1234");
 
918
        g_object_set_data (G_OBJECT (radio_none), "pin", "NULL");
975
919
        g_object_set_data (G_OBJECT (radio_custom), "entry", entry_custom);
976
920
 
977
921
        gtk_builder_connect_signals(builder, NULL);
983
927
        return assistant;
984
928
}
985
929
 
986
 
static UniqueResponse
987
 
message_received_cb (UniqueApp         *app,
988
 
                     int                command,
989
 
                     UniqueMessageData *message_data,
990
 
                     guint              time_,
991
 
                     gpointer           user_data)
 
930
static void
 
931
activate_cb (GApplication      *app,
 
932
             gpointer           user_data)
992
933
{
993
 
        gtk_window_present (GTK_WINDOW (user_data));
994
 
 
995
 
        return UNIQUE_RESPONSE_OK;
 
934
        gtk_window_present_with_time (GTK_WINDOW (user_data), GDK_CURRENT_TIME);
996
935
}
997
936
 
998
937
static GOptionEntry options[] = {
1001
940
 
1002
941
int main (int argc, char **argv)
1003
942
{
1004
 
        UniqueApp *app;
 
943
        GtkApplication *app;
1005
944
        GError *error = NULL;
1006
945
 
1007
946
        bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
1019
958
                return 1;
1020
959
        }
1021
960
 
1022
 
        app = unique_app_new ("org.gnome.Bluetooth.wizard", NULL);
1023
 
        if (unique_app_is_running (app)) {
 
961
        app = gtk_application_new ("org.gnome.Bluetooth.wizard", G_APPLICATION_FLAGS_NONE);
 
962
        if (g_application_register (G_APPLICATION (app), NULL, &error) == FALSE) {
 
963
                g_warning ("Could not register application: %s", error->message);
 
964
                g_error_free (error);
 
965
                return 1;
 
966
        }
 
967
 
 
968
        if (g_application_get_is_remote (G_APPLICATION (app))) {
 
969
                g_application_activate (G_APPLICATION (app));
1024
970
                gdk_notify_startup_complete ();
1025
 
                unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
1026
971
                return 0;
1027
972
        }
1028
973
 
1033
978
        client = bluetooth_client_new();
1034
979
 
1035
980
        agent = bluetooth_agent_new();
 
981
        g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *) (&agent));
1036
982
 
1037
983
        bluetooth_agent_set_pincode_func(agent, pincode_callback, NULL);
1038
984
        bluetooth_agent_set_display_func(agent, display_callback, NULL);
1046
992
        window_assistant = create_wizard();
1047
993
        if (window_assistant == NULL)
1048
994
                return 1;
1049
 
 
1050
 
        g_signal_connect (app, "message-received",
1051
 
                          G_CALLBACK (message_received_cb), window_assistant);
1052
 
 
1053
 
        gtk_main();
 
995
        gtk_application_add_window (app,
 
996
                                    GTK_WINDOW (window_assistant));
 
997
 
 
998
        g_signal_connect (app, "activate",
 
999
                          G_CALLBACK (activate_cb), window_assistant);
 
1000
 
 
1001
        g_application_run (G_APPLICATION (app), argc, argv);
1054
1002
 
1055
1003
        bluetooth_plugin_manager_cleanup ();
1056
1004
 
1057
 
        g_object_unref(agent);
 
1005
        if (agent != NULL)
 
1006
                g_object_unref (agent);
1058
1007
 
1059
1008
        g_object_unref(client);
1060
1009