Back to index

indicator-datetime  12.10.0
datetime-prefs-locations.h File Reference
#include <gtk/gtk.h>
#include <timezonemap/cc-timezone-map.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


G_BEGIN_DECLS GtkWidget * datetime_setup_locations_dialog (CcTimezoneMap *map)

Function Documentation

G_BEGIN_DECLS GtkWidget* datetime_setup_locations_dialog ( CcTimezoneMap *  map)

Definition at line 586 of file datetime-prefs-locations.c.

  GError * error = NULL;
  GtkBuilder * builder = gtk_builder_new ();
  gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
  gtk_builder_add_from_file (builder, DATETIME_DIALOG_UI_FILE, &error);
  if (error != NULL) {
    /* We have to abort, we can't continue without the ui file */
    g_error ("Could not load ui file %s: %s", DATETIME_DIALOG_UI_FILE, error->message);
    g_error_free (error);
    return NULL;

  GSettings * conf = g_settings_new (SETTINGS_INTERFACE);

#define WIG(name) GTK_WIDGET (gtk_builder_get_object (builder, name))

  GtkWidget * dlg = WIG ("locationsDialog");
  GtkWidget * tree = WIG ("locationsView");
  GObject * store = gtk_builder_get_object (builder, "locationsStore");

  /* Configure tree */
  CcTimezoneCompletion * completion = cc_timezone_completion_new ();
  g_object_set_data (G_OBJECT (completion), "tzmap", map);
  g_object_set_data (G_OBJECT (completion), "store", store);
  g_signal_connect (completion, "match-selected", G_CALLBACK (timezone_selected), dlg);

  GtkCellRenderer * cell = gtk_cell_renderer_text_new ();
  g_object_set (cell, "editable", TRUE, NULL);
  g_signal_connect (cell, "editing-started", G_CALLBACK (handle_edit_started), completion);
  g_signal_connect (cell, "edited", G_CALLBACK (handle_edit), store);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
                                               _("Location"), cell,
                                               "text", COL_VISIBLE_NAME, NULL);
  GtkTreeViewColumn * loc_col = gtk_tree_view_get_column (GTK_TREE_VIEW (tree), 0);
  gtk_tree_view_column_set_expand (loc_col, TRUE);
  g_object_set_data (G_OBJECT (completion), "name-cell", cell);

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (loc_col, cell, FALSE);
  gtk_tree_view_column_add_attribute (loc_col, cell, "icon-name", COL_ICON);

  gtk_widget_set_has_tooltip (tree, TRUE);
  g_signal_connect (tree, "query-tooltip", G_CALLBACK (query_tooltip), cell);

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_renderer_set_alignment (cell, 1.0f, 0.5f);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
                                               _("Time"), cell,
                                               "text", COL_TIME, NULL);

  GtkTreeSelection * selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
  g_signal_connect (selection, "changed", G_CALLBACK (selection_changed), WIG ("removeButton"));
  selection_changed (selection, WIG ("removeButton"));

  g_signal_connect (WIG ("addButton"), "clicked", G_CALLBACK (handle_add), tree);
  g_signal_connect (WIG ("removeButton"), "clicked", G_CALLBACK (handle_remove), tree);

  GtkWidget * w = WIG ("sortByNameButton");
  g_signal_connect (w, "clicked", G_CALLBACK (handle_sort_by_name), tree);
  g_object_set_data (G_OBJECT(dlg), "sortByNameButton", w);

  w = WIG ("sortByTimeButton");
  g_signal_connect (w, "clicked", G_CALLBACK (handle_sort_by_time), tree);
  g_object_set_data (G_OBJECT(dlg), "sortByTimeButton", w);

  fill_from_settings (store, conf);
  g_signal_connect_swapped (store, "row-deleted", G_CALLBACK (model_changed), dlg);
  g_signal_connect_swapped (store, "row-inserted", G_CALLBACK (model_changed), dlg);
  g_signal_connect_swapped (store, "row-changed", G_CALLBACK (model_changed), dlg);
  g_signal_connect_swapped (store, "rows-reordered", G_CALLBACK (model_changed), dlg);
  g_object_set_data_full (G_OBJECT (dlg), "conf", g_object_ref (conf), g_object_unref);
  g_object_set_data_full (G_OBJECT (dlg), "completion", completion, g_object_unref);
  g_signal_connect (dlg, "destroy", G_CALLBACK (dialog_closed), store);

  guint time_id = g_timeout_add_seconds (2, (GSourceFunc)update_times, dlg);
  g_object_set_data (G_OBJECT (dlg), "time-id", GINT_TO_POINTER(time_id));
  update_times (dlg);

#undef WIG

  g_object_unref (conf);
  g_object_unref (builder);

  return dlg;

Here is the call graph for this function:

Here is the caller graph for this function: