~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to applets/clock/clock-location.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Sebastien Bacher, Jeremy Bicha
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.13.10 upstream) (2.2.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110530110449-hinl17kxkcefjw6x
Tags: 1:3.0.2-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in:
  - the new libgweather version is in oneiric, use it
  - drop the python and python-gconf depends, 
    they were added for gnome-panel-add which is still using gconf and buggy
* debian/gnome-panel-data.install:
  - don't install the apport hook, it's only getting gconf datas which 
    doesn't work since gnome-panel uses gsettings
* debian/patches/90_build_fixes.patch:
  - restore build fix from git not applied in the new serie
* debian/patches/01_panel_submenus.patch:
  - don't take that Debian diff, the .menus use the upstream naming in Ubuntu
* debian/patches/06_no_resize_grip.patch:
  - dropped, the issue is fixed in the new version
* debian/patches/50_fix-potfiles.patch:
  - dropped, the issue is fixed in the new version
* debian/watch:
  - track unstable series as well

Drop those delta, since gnome-panel is not the default Ubuntu session now we
can go back to an experience closer to the upstream one: 
* debian/control.in:
  - drop the indicators recommends, unity-2d is the ubuntu fallback session
    so we can get back to use an upstream config for gnome-panel and reduce
    the delta we carry
* debian/patches/04_default_panel_config.patch:
  - don't modify the upstream layout
* debian/patches/05_no_session_delay.patch:
  - no need to tweak the upstream session to optimize it
* debian/patches/16_compiz_workspace_switcher.patch:
  - go back to the upstream switcher behaviour    
* debian/patches/25_dynamic_fusa_detection.patch:
  - not needed since we use the upstream layout, could be ported if someone
    is wanting to do the work though
* debian/patches/30_disable-initial-animation.patch, debian/rules:
  - drop the --disable-initial-animation, that was some login optimization
    but since it's not the default desktop you should go back to the 
    upstream behaviour

[ Jeremy Bicha ]   
* New upstream version
* Merge from Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Recommends gnome-settings-daemon which has the timezone polkit service
* debian/rules:
  - Update translations template.
* debian/gnome-panel-data.install:
  - Install apport hook
  - Install the "About Ubuntu" menu item.
* debian/patches/01_layout.patch:
  - Disabled, Help & About Ubuntu don't fit as well in Gnome Panel 3
* debian/patches/01_panel_submenus.patch.
  - Dropped
* debian/patches/03_dnd_places_link.patch:
  - Disabled, when using Drag'n'Drop from Places menu, install a link launcher
    (.desktop file) instead of copying the entire directory.
* debian/patches/17_about-ubuntu-translation.patch:
  - List ubuntu-about.desktop for translation.
* debian/patches/40_unset_menuproxy.patch:
  - Make sure gnome-panel and the applets don't pick up menu proxies.
* debian/patches/50_fix-potfiles.patch
  - Fix i18n
* debian/patches/85_disable_shutdown_on_ltsp.patch:
  - Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/71_change_bookmark_submenu_limit_value.patch
  - Dropped, picked up by Debian
* debian/patches/18_lockdown_lock_editor.patch:
* debian/patches/90_git_wnck_show_realize.patch:
* debian/patches/90_fix_linking_DSO_link.patch:
* debian/patches/91_gir_annotations.patch
* debian/patches/92_git_calendar_day.patch
* debian/patches/92_git_fix_applets_in_multiscreen.patch:
  - Dropped, applied upstream
* debian/watch:
  - watch unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <gio/gio.h>
18
18
 
19
19
#ifdef HAVE_NETWORK_MANAGER
20
 
#include <dbus/dbus-glib.h>
21
 
#include <dbus/dbus-glib-lowlevel.h>
22
20
#include <NetworkManager/NetworkManager.h>
23
21
#endif
24
22
 
502
500
} MakeCurrentData;
503
501
 
504
502
static void
505
 
make_current_cb (gpointer data, GError *error)
 
503
make_current_cb (GObject      *source,
 
504
                 GAsyncResult *result,
 
505
                 gpointer      user_data)
506
506
{
507
 
        MakeCurrentData *mcdata = data;
 
507
        MakeCurrentData *mcdata = user_data;
 
508
        GError *error = NULL;
 
509
 
 
510
        set_system_timezone_finish (result, &error);
508
511
 
509
512
        if (error == NULL) {
510
513
                if (current_location)
521
524
                mcdata->callback (mcdata->data, error);
522
525
        else
523
526
                g_error_free (error);
524
 
}
525
527
 
526
 
static void
527
 
free_make_current_data (gpointer data)
528
 
{
529
 
        MakeCurrentData *mcdata = data;
530
 
        
531
528
        if (mcdata->destroy)
532
529
                mcdata->destroy (mcdata->data);
533
530
        
537
534
 
538
535
void
539
536
clock_location_make_current (ClockLocation *loc,
540
 
                             guint          transient_parent_xid,
541
537
                             GFunc          callback,
542
538
                             gpointer       data,
543
539
                             GDestroyNotify destroy)
544
540
{
545
541
        ClockLocationPrivate *priv = PRIVATE (loc);
546
 
        gchar *filename;
547
542
        MakeCurrentData *mcdata;
548
543
 
549
544
        if (loc == current_location) {
575
570
        mcdata->data = data;
576
571
        mcdata->destroy = destroy;
577
572
 
578
 
        filename = g_build_filename (SYSTEM_ZONEINFODIR, priv->timezone, NULL);
579
 
        set_system_timezone_async (filename,
580
 
                                   (GFunc)make_current_cb,
581
 
                                   mcdata,
582
 
                                   free_make_current_data);
583
 
        g_free (filename);
 
573
        set_system_timezone_async (priv->timezone,
 
574
                                   make_current_cb,
 
575
                                   mcdata);
584
576
}
585
577
 
586
578
static gchar *
707
699
 
708
700
static GList *locations = NULL;
709
701
 
 
702
#ifdef HAVE_NETWORK_MANAGER
710
703
static void
711
704
update_weather_infos (void)
712
705
{
721
714
        }
722
715
}
723
716
 
724
 
#ifdef HAVE_NETWORK_MANAGER
725
717
static void
726
 
state_notify (DBusPendingCall *pending, gpointer data)
 
718
network_monitor_signal (GDBusProxy  *proxy,
 
719
                        const gchar *sender_name,
 
720
                        const gchar *signal_name,
 
721
                        GVariant    *parameters,
 
722
                        gpointer     user_data)
727
723
{
728
 
        DBusMessage *msg = dbus_pending_call_steal_reply (pending);
729
 
 
730
 
        if (!msg)
731
 
                return;
732
 
 
733
 
        if (dbus_message_get_type (msg) == DBUS_MESSAGE_TYPE_METHOD_RETURN) {
734
 
                dbus_uint32_t result;
735
 
 
736
 
                if (dbus_message_get_args (msg, NULL, 
737
 
                                           DBUS_TYPE_UINT32, &result,
738
 
                                           DBUS_TYPE_INVALID)) {
739
 
                        if (result == NM_STATE_CONNECTED) {
 
724
        if (g_str_equal (signal_name, "StateChanged")) {
 
725
                if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(u)"))) {
 
726
                        guint32 state;
 
727
 
 
728
                        g_variant_get (parameters, "(u)", &state);
 
729
 
 
730
                        if (state == NM_STATE_CONNECTED) {
740
731
                                update_weather_infos ();
741
732
                        }
742
733
                }
743
734
        }
744
 
 
745
 
        dbus_message_unref (msg);
746
 
}
747
 
 
748
 
static void 
749
 
check_network (DBusConnection *connection)
750
 
{
751
 
        DBusMessage *message;
752
 
        DBusPendingCall *reply;
753
 
 
754
 
        message = dbus_message_new_method_call (NM_DBUS_SERVICE,
755
 
                                                NM_DBUS_PATH,
756
 
                                                NM_DBUS_INTERFACE,
757
 
                                                "state");
758
 
        if (dbus_connection_send_with_reply (connection, message, &reply, -1)) {
759
 
                dbus_pending_call_set_notify (reply, state_notify, NULL, NULL);
760
 
                dbus_pending_call_unref (reply);
761
 
        }
762
 
        
763
 
        dbus_message_unref (message);
764
 
}
765
 
 
766
 
static DBusHandlerResult
767
 
filter_func (DBusConnection *connection,
768
 
             DBusMessage    *message,
769
 
             void           *user_data)
770
 
{
771
 
        if (dbus_message_is_signal (message,
772
 
                                    NM_DBUS_INTERFACE, 
773
 
                                    "StateChanged")) {
774
 
                check_network (connection);
775
 
 
776
 
                return DBUS_HANDLER_RESULT_HANDLED;
777
 
        }
778
 
 
779
 
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
780
735
}
781
736
 
782
737
static void
783
738
setup_network_monitor (void)
784
739
{
785
 
        GError *error;
786
 
        DBusError derror;
787
 
        static DBusGConnection *bus = NULL;
788
 
        DBusConnection *dbus;
789
 
 
790
 
        if (bus == NULL) {
791
 
                error = NULL;
792
 
                bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
793
 
                if (bus == NULL) {
794
 
                        g_warning ("Couldn't connect to system bus: %s",
795
 
                                   error->message);
796
 
                        g_error_free (error);
797
 
 
 
740
        static GDBusProxy *proxy;
 
741
        GError *error = NULL;
 
742
 
 
743
        if (proxy == NULL) {
 
744
                proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
 
745
                                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
 
746
                                                       NULL, NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE,
 
747
                                                       NULL, &error);
 
748
 
 
749
                if (proxy == NULL) {
 
750
                        g_warning ("Couldn't create NetworkManager proxy: %s",
 
751
                                   error->message);
 
752
                        g_error_free (error);
798
753
                        return;
799
 
                }
800
 
 
801
 
                dbus_error_init (&derror);
802
 
                dbus = dbus_g_connection_get_connection (bus);
803
 
                dbus_connection_add_filter (dbus, filter_func, NULL, NULL);
804
 
                dbus_bus_add_match (dbus,
805
 
                                    "type='signal',"
806
 
                                    "interface='" NM_DBUS_INTERFACE "'",
807
 
                                    &derror);
808
 
                if (dbus_error_is_set (&derror)) {
809
 
                        g_warning ("Couldn't register signal handler: %s: %s",
810
 
                                   derror.name, derror.message);
811
 
                        dbus_error_free (&derror);
812
754
                }
813
 
        }
 
755
 
 
756
                g_signal_connect (proxy, "g-signal", G_CALLBACK (network_monitor_signal), NULL);
 
757
        }
814
758
}
815
759
#endif
816
760