Compare commits

...

16 Commits

Author SHA1 Message Date
Stéphane Maniaci
fd4d344466 Solve a week of headbanging with g_variant_ref_sink () 2011-07-22 20:21:08 +02:00
Stéphane Maniaci
30cc7383ad simplify dictionnary creation 2011-07-15 16:56:26 +02:00
Stéphane Maniaci
d97962722a Add some helper functions to deal with GVariant arrays. 2011-07-14 23:03:05 +02:00
Stéphane Maniaci
d5cf248a05 remove a todo note 2011-07-14 11:42:49 +02:00
Stéphane Maniaci
7f418dc729 Use correct response ID in the add-location dialog 2011-07-13 20:44:53 +02:00
Stéphane Maniaci
621503cb84 Add the missing UI file 2011-07-13 18:00:53 +02:00
Stéphane Maniaci
086fac304c [location] add the dialog to append a location to the store
right now it's just a plain text stupid dialog that allow me to
test settings/data saving, and hooking up to the Shell. In the very
near future, it should be done with geocode-glib, or fallback to
LibGWeather, and stop being ugly.
2011-07-08 00:57:36 +02:00
Stéphane Maniaci
a0e9b3990b [location] add a nice TODO 2011-07-08 00:55:13 +02:00
Stéphane Maniaci
9b16268fe1 [location] remove useless signals in the builder file 2011-07-08 00:06:43 +02:00
Stéphane Maniaci
329828fb15 [location] remove pre-existing data in the UI file 2011-07-07 23:36:23 +02:00
Stéphane Maniaci
c38fc46243 [location] hook up the 24hr switch with the system settings 2011-07-07 23:17:40 +02:00
Stéphane Maniaci
3b8cd2c21d [location] Add the map pixmap 2011-07-06 00:24:07 +02:00
Stéphane Maniaci
cabfddad05 [location] better styling of the inline toolbar 2011-07-06 00:06:53 +02:00
Stéphane Maniaci
a8fe550f65 [location] properly rename widgets in the UI file
So that nobody knows I stole them from the printers panel.
2011-07-06 00:06:53 +02:00
Stéphane Maniaci
75447db955 Add a broken location panel
This should in time replace Date & Time
settings, althought I'm not sure about how
it overlaps with Region & Language, and other
things. Need designer input.
2011-07-05 21:33:37 +02:00
Stéphane Maniaci
ab65280445 Add a locations panel 2011-07-04 17:45:59 +02:00
12 changed files with 1048 additions and 1 deletions

View File

@@ -109,6 +109,7 @@ PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES dbus-glib-1
PKG_CHECK_MODULES(REGION_PANEL, $COMMON_MODULES libgnomekbd >= 2.91.91
libxklavier >= 5.1 libgnomekbdui >= 2.91.91)
PKG_CHECK_MODULES(SCREEN_PANEL, $COMMON_MODULES)
PKG_CHECK_MODULES(LOCATION_PANEL, $COMMON_MODULES)
PKG_CHECK_MODULES(SOUND_PANEL, $COMMON_MODULES libxml-2.0
libcanberra-gtk3 >= $CANBERRA_REQUIRED_VERSION
libpulse >= $PA_REQUIRED_VERSION
@@ -361,6 +362,8 @@ panels/sound/data/icons/scalable/devices/Makefile
panels/sound/data/sounds/Makefile
panels/screen/Makefile
panels/screen/gnome-screen-panel.desktop.in
panels/location/Makefile
panels/location/gnome-location-panel.desktop.in
panels/info/Makefile
panels/info/gnome-info-panel.desktop.in
panels/power/Makefile

View File

@@ -14,7 +14,8 @@ SUBDIRS= \
keyboard \
universal-access \
user-accounts \
datetime
datetime \
location
if BUILD_PRINTERS
SUBDIRS += printers

View File

@@ -0,0 +1,38 @@
cappletname = location
INCLUDES = \
$(PANEL_CFLAGS) \
$(LOCATION_PANEL_CFLAGS) \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
$(NULL)
ccpanelsdir = $(PANELS_DIR)
ccpanels_LTLIBRARIES = liblocation.la
liblocation_la_SOURCES = \
location-module.c \
location-utils.h \
location-utils.c \
cc-location-panel.c \
cc-location-panel.h
liblocation_la_LIBADD = $(PANEL_LIBS) $(LOCATION_PANEL_LIBS)
liblocation_la_LDFLAGS = $(PANEL_LDFLAGS)
uidir = $(pkgdatadir)/ui/location
dist_ui_DATA = \
add-location.ui \
location.ui \
data/bg.png
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = gnome-location-panel.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
CLEANFILES = $(desktop_in_files) $(desktop_DATA)
-include $(top_srcdir)/git.mk

View File

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="add-location-dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Add a location</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="column_homogeneous">True</property>
<property name="n_columns">2</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">City:</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Country:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Timezone:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="city-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="country-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="tz-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button2</action-widget>
<action-widget response="-5">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@@ -0,0 +1,299 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 Red Hat, Inc
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
*
* 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.
*
*/
/* TODO:
- use geocode-glib to ask for locations ;
- use an indicator for the home location (add a pixbuf column) ;
- fallback to libgweather locations.xml when no Internet available ;
- draw pretty Cairos shapes to spot locations on the map (otherwise the map is useless) ;
- think about how to handle timezone change (are they just an hour offset?) ;
- think about how location change affect manual timing ;
- who takes care of daylight saving and summer time and all the fun stuff? ;
- think about where does my panel fit (seperate panel? replace date & time?) ;
- define a nice schema for GSettings ;
*/
#include "cc-location-panel.h"
#include "location-utils.h"
#include <gdesktop-enums.h>
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
#define CLOCK_FORMAT_KEY "clock-format"
G_DEFINE_DYNAMIC_TYPE (CcLocationPanel, cc_location_panel, CC_TYPE_PANEL)
#define LOCATION_PANEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_LOCATION_PANEL, CcLocationPanelPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (self->priv->builder, s))
struct _CcLocationPanelPrivate
{
GtkBuilder *builder;
GSettings *settings;
GSettings *location_settings;
GVariant *locations;
GDesktopClockFormat clock_format;
GtkListStore *location_store;
/* that's where private vars go I guess */
};
static void
populate_locations (GtkListStore *store,
GVariant *locations)
{
GtkTreeIter iter;
GVariantIter viter;
GVariant *dict;
GVariant *value;
g_variant_iter_init (&viter, locations);
while ((dict = g_variant_iter_next_value (&viter))) {
gtk_list_store_append (store, &iter);
value = g_variant_lookup_value (dict,
"city",
G_VARIANT_TYPE_STRING);
gtk_list_store_set (store, &iter, 0, g_variant_get_string (value, NULL), -1);
value = g_variant_lookup_value (dict,
"country",
G_VARIANT_TYPE_STRING);
gtk_list_store_set (store, &iter, 1, g_variant_get_string (value, NULL), -1);
value = g_variant_lookup_value (dict,
"timezone",
G_VARIANT_TYPE_INT16);
int timezone = g_variant_get_int16 (value);
char *tz;
if (timezone > 0)
tz = g_strdup_printf ("GMT +%i", timezone);
else
tz = g_strdup_printf ("GMT -%i", timezone);
gtk_list_store_set (store, &iter, 2, tz, -1);
g_free (tz);
gtk_list_store_set (store, &iter, 3, "20:00", -1);
/*value = g_variant_lookup_value (dict,
"longitude",
G_VARIANT_TYPE_DOUBLE);
gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
value = g_variant_lookup_value (dict,
"latitude",
G_VARIANT_TYPE_DOUBLE);
gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
*/
}
}
static void
_on_add_location (GtkToolButton *bt,
CcLocationPanel *self)
{
CcLocationPanelPrivate *priv = self->priv;
GError *e = NULL;
gtk_builder_add_from_file (self->priv->builder, GNOMECC_UI_DIR "/add-location.ui", &e);
g_assert_no_error (e);
GtkWidget *dialog = WID ("add-location-dialog");
int res = gtk_dialog_run (GTK_DIALOG (dialog));
switch (res) {
case GTK_RESPONSE_OK:
printf ("Dialog response OK\n");
// FIXME: column ids
const char *city = gtk_entry_get_text (GTK_ENTRY (WID ("city-entry")));
const char *ctry = gtk_entry_get_text (GTK_ENTRY (WID ("country-entry")));
//const char *tz = gtk_entry_get_text (GTK_ENTRY (WID ("tz-entry")));
const double longitude = 0.23;
const double latitude = 0.32;
GVariant *newloc = g_variant_location_new (city, ctry,
3, longitude, latitude);
priv->locations = g_variant_array_add_value (priv->locations, newloc);
g_assert (g_settings_set_value (priv->location_settings,
"locations",
priv->locations));
gtk_list_store_clear (priv->location_store);
populate_locations (priv->location_store,
priv->locations);
break;
default:
break;
}
gtk_widget_destroy (dialog);
}
static void
_on_24hr_time_switch (GObject *gobject,
GParamSpec *pspec,
CcLocationPanel *self)
{
CcLocationPanelPrivate *priv = self->priv;
GDesktopClockFormat value;
//g_signal_handlers_block_by_func (priv->settings, clock_settings_changed_cb,
// panel);
if (gtk_switch_get_active (GTK_SWITCH (WID ("24h_time_switch"))))
value = G_DESKTOP_CLOCK_FORMAT_24H;
else
value = G_DESKTOP_CLOCK_FORMAT_12H;
g_settings_set_enum (priv->settings, CLOCK_FORMAT_KEY, value);
priv->clock_format = value;
/* update_time (panel); */
/* g_signal_handlers_unblock_by_func (priv->settings, clock_settings_changed_cb, */
/* panel); */
}
static void
cc_location_panel_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_location_panel_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_location_panel_dispose (GObject *object)
{
CcLocationPanelPrivate *priv = CC_LOCATION_PANEL (object)->priv;
G_OBJECT_CLASS (cc_location_panel_parent_class)->dispose (object);
if (priv->settings) {
g_object_unref (priv->settings);
priv->settings = NULL;
}
}
static void
cc_location_panel_finalize (GObject *object)
{
CcLocationPanelPrivate *priv = CC_LOCATION_PANEL (object)->priv;
G_OBJECT_CLASS (cc_location_panel_parent_class)->finalize (object);
}
static void
cc_location_panel_class_init (CcLocationPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcLocationPanelPrivate));
object_class->get_property = cc_location_panel_get_property;
object_class->set_property = cc_location_panel_set_property;
object_class->dispose = cc_location_panel_dispose;
object_class->finalize = cc_location_panel_finalize;
}
static void
cc_location_panel_class_finalize (CcLocationPanelClass *klass)
{
}
static void
cc_location_panel_init (CcLocationPanel *self)
{
GError *error;
GtkWidget *widget;
GtkStyleContext *context;
self->priv = LOCATION_PANEL_PRIVATE (self);
self->priv->settings = g_settings_new (CLOCK_SCHEMA);
self->priv->builder = gtk_builder_new ();
self->priv->location_settings = g_settings_new ("org.gnome.desktop.location");
error = NULL;
gtk_builder_add_from_file (self->priv->builder,
GNOMECC_UI_DIR "/location.ui",
&error);
if (error != NULL)
{
g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return;
}
gtk_builder_connect_signals (self->priv->builder, NULL);
self->priv->location_store = (GtkListStore *) gtk_builder_get_object (self->priv->builder,
"locations-store");
widget = WID ("locations-scrolledwindow");
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
widget = WID ("location-edit-toolbar");
context = gtk_widget_get_style_context (widget);
gtk_style_context_add_class (context, "inline-toolbar");
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
widget = WID ("24h_time_switch");
gtk_switch_set_active (GTK_SWITCH (widget),
g_settings_get_enum (self->priv->settings, CLOCK_FORMAT_KEY) ==
G_DESKTOP_CLOCK_FORMAT_24H);
g_signal_connect (widget, "notify::active",
G_CALLBACK (_on_24hr_time_switch), self);
widget = WID ("location-add-button");
g_signal_connect (widget, "clicked",
G_CALLBACK (_on_add_location), self);
widget = WID ("location-vbox");
gtk_widget_reparent (widget, (GtkWidget *) self);
self->priv->locations = g_settings_get_value (self->priv->location_settings,
"locations");
populate_locations (self->priv->location_store, self->priv->locations);
}
void
cc_location_panel_register (GIOModule *module)
{
cc_location_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_LOCATION_PANEL,
"location", 0);
}

View File

@@ -0,0 +1,73 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 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.
*
*/
#ifndef _CC_LOCATION_PANEL_H
#define _CC_LOCATION_PANEL_H
#include <libgnome-control-center/cc-panel.h>
G_BEGIN_DECLS
#define CC_TYPE_LOCATION_PANEL cc_location_panel_get_type()
#define CC_LOCATION_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_LOCATION_PANEL, CcLocationPanel))
#define CC_LOCATION_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_LOCATION_PANEL, CcLocationPanelClass))
#define CC_IS_LOCATION_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_LOCATION_PANEL))
#define CC_IS_LOCATION_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_LOCATION_PANEL))
#define CC_LOCATION_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_LOCATION_PANEL, CcLocationPanelClass))
typedef struct _CcLocationPanel CcLocationPanel;
typedef struct _CcLocationPanelClass CcLocationPanelClass;
typedef struct _CcLocationPanelPrivate CcLocationPanelPrivate;
struct _CcLocationPanel
{
CcPanel parent;
CcLocationPanelPrivate *priv;
};
struct _CcLocationPanelClass
{
CcPanelClass parent_class;
};
GType cc_location_panel_get_type (void) G_GNUC_CONST;
void cc_location_panel_register (GIOModule *module);
G_END_DECLS
#endif /* _CC_LOCATION_PANEL_H */

BIN
panels/location/data/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View File

@@ -0,0 +1,17 @@
[Desktop Entry]
_Name=Location
_Comment=Geographical locations and timezones
Exec=gnome-control-center location
Icon=start-here
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PersonalSettings
OnlyShowIn=GNOME;Unity;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center
X-GNOME-Bugzilla-Component=location
X-GNOME-Bugzilla-Version=@VERSION@
X-GNOME-Settings-Panel=location
# Translators: those are keywords for the brightness and lock control-center panel
_X-GNOME-Keywords=Location;Region;Date;Time;Weather;Timezone;

View File

@@ -0,0 +1,41 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 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.
*
*
*/
#include <config.h>
#include "cc-location-panel.h"
#include <glib/gi18n-lib.h>
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
/* register the panel */
cc_location_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright 2009-2010 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 3 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.
*
*/
#include "location-utils.h"
#include "config.h"
#include <glib.h>
GVariant *
g_variant_location_new (const char *city,
const char *country,
const int timezone,
const double latitude,
const double longitude)
{
g_debug ("Creating a new GVariant");
GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_DICTIONARY);
g_variant_builder_add_parsed (builder, "{'city', <%s>}", city);
g_variant_builder_add_parsed (builder, "{'country', <%s>}", country);
g_variant_builder_add_parsed (builder, "{'timezone', <%n>}", timezone);
g_variant_builder_add_parsed (builder, "{'longitude', <%d>}", longitude);
g_variant_builder_add_parsed (builder, "{'latitude', <%d>}", latitude);
GVariant *val = g_variant_builder_end (builder);
return val;
}
GVariant *
g_variant_array_add_value (GVariant *container,
GVariant *value)
{
GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
GVariantIter iter;
GVariant *val;
g_variant_iter_init (&iter, container);
while ((val = g_variant_iter_next_value (&iter))) {
g_variant_builder_add_value (builder, val);
}
g_variant_builder_add_value (builder, value);
GVariant *res = g_variant_builder_end (builder);
g_variant_builder_unref (builder);
g_variant_ref_sink (res);
return res;
}

View File

@@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright 2009-2010 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 3 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 __LOCATION_UTILS_H__
#define __LOCATION_UTILS_H__
#include <glib.h>
G_BEGIN_DECLS
GVariant *
g_variant_location_new (const char *city,
const char *country,
const int timezone,
const double latitude,
const double longitude);
GVariant *
g_variant_array_add_value (GVariant *container,
GVariant *value);
void
g_variant_location_print (GVariant *location);
G_END_DECLS
#endif /* __LOCATION_UTILS_H */

306
panels/location/location.ui Normal file
View File

@@ -0,0 +1,306 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkListStore" id="locations-store">
<columns>
<!-- column-name city-name -->
<column type="gchararray"/>
<!-- column-name country -->
<column type="gchararray"/>
<!-- column-name timezone -->
<column type="gchararray"/>
<!-- column-name time -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="main-window">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<child>
<object class="GtkBox" id="location-vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="pixbuf">bg.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkSwitch" id="networktime-switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="use_action_appearance">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Automatically set time</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="conf_button">
<property name="label" translatable="yes">Configure time...</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Use 24-hour time</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="24h_time_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="locations-scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="min_content_height">133</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">locations-store</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="citynamecolumn">
<property name="title" translatable="yes">city</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="countrycolumn">
<property name="title" translatable="yes">country</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2">
<property name="style">oblique</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="tzcolumn">
<property name="title" translatable="yes">tz</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3">
<property name="xalign">1</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="timecolumn">
<property name="title" translatable="yes">time</property>
<property name="alignment">1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4">
<property name="xpad">26</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<property name="scale">1.3300000000000001</property>
</object>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="location-edit-toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_size">1</property>
<child>
<object class="GtkToolButton" id="location-add-button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label">AddPrinter</property>
<property name="use_underline">True</property>
<property name="icon_name">list-add-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="location-remove-button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label">RemovePrinter</property>
<property name="use_underline">True</property>
<property name="icon_name">list-remove-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="location-mark-button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">HomeLocation</property>
<property name="use_underline">True</property>
<property name="icon_name">user-home-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</interface>