/*
- * Copyright (C) 2010-2013 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
G_CALLBACK(cb_about) },
{ "QuitAction",
- GTK_STOCK_QUIT, "_Quit", NULL, "Quit", G_CALLBACK(cb_menu_quit) }
+ GTK_STOCK_QUIT,
+ N_("_Quit"),
+ NULL, N_("Quit"),
+ G_CALLBACK(cb_menu_quit) }
};
static guint n_entries = G_N_ELEMENTS(entries);
update_menu_item(GtkMenuItem *item, struct psensor *s, int use_celcius)
{
gchar *str;
- double v;
+ char *v;
- v = psensor_get_current_value(s);
+ v = psensor_current_value_to_str(s, use_celcius);
- if (is_temp_type(s->type) && !use_celcius)
- v = celcius_to_fahrenheit(v);
-
- str = g_strdup_printf("%s: %2.f %s",
- s->name,
- v,
- psensor_type_to_unit_str(s->type, use_celcius));
+ str = g_strdup_printf("%s: %s", s->name, v);
gtk_menu_item_set_label(item, str);
+ free(v);
g_free(str);
}
update_menu_item(*m, *s, use_celcius);
}
-static GtkWidget *get_menu(struct ui_psensor *ui)
+static void
+build_sensor_menu_items(const struct ui_psensor *ui,
+ GtkMenu *menu)
{
- GtkActionGroup *action_group;
- GtkUIManager *menu_manager;
- GError *error;
- GtkMenu *menu;
- int i, n, j;
- int celcius;
+ int i, j, n, celcius;
const char *name;
+ struct psensor **sorted_sensors;
- action_group = gtk_action_group_new("PsensorActions");
- gtk_action_group_set_translation_domain(action_group, PACKAGE);
- menu_manager = gtk_ui_manager_new();
-
- gtk_action_group_add_actions(action_group, entries, n_entries, ui);
- gtk_ui_manager_insert_action_group(menu_manager, action_group, 0);
-
- error = NULL;
- gtk_ui_manager_add_ui_from_string(menu_manager, menu_desc, -1, &error);
-
- if (error)
- g_error(_("building menus failed: %s"), error->message);
-
- menu = GTK_MENU(gtk_ui_manager_get_widget(menu_manager, "/MainMenu"));
+ free(menu_items);
celcius = ui->config->temperature_unit == CELCIUS;
- n = psensor_list_size(ui->sensors);
+ sorted_sensors = ui_get_sensors_ordered_by_position(ui);
+ n = psensor_list_size(sorted_sensors);
menu_items = malloc(n * sizeof(GtkWidget *));
sensors = malloc((n + 1) * sizeof(struct psensor *));
for (i = 0, j = 0; i < n; i++) {
- if (config_is_appindicator_enabled(ui->sensors[i]->id)) {
- sensors[j] = ui->sensors[i];
+ if (config_is_appindicator_enabled(sorted_sensors[i]->id)) {
+ sensors[j] = sorted_sensors[i];
name = sensors[j]->name;
menu_items[j] = GTK_MENU_ITEM
sensors[j] = NULL;
+ free(sorted_sensors);
+}
+
+static GtkWidget *get_menu(struct ui_psensor *ui)
+{
+ GtkActionGroup *action_group;
+ GtkUIManager *menu_manager;
+ GError *error;
+ GtkMenu *menu;
+
+ action_group = gtk_action_group_new("PsensorActions");
+ gtk_action_group_set_translation_domain(action_group, PACKAGE);
+ menu_manager = gtk_ui_manager_new();
+
+ gtk_action_group_add_actions(action_group, entries, n_entries, ui);
+ gtk_ui_manager_insert_action_group(menu_manager, action_group, 0);
+
+ error = NULL;
+ gtk_ui_manager_add_ui_from_string(menu_manager, menu_desc, -1, &error);
+
+ if (error)
+ g_error(_("building menus failed: %s"), error->message);
+
+ menu = GTK_MENU(gtk_ui_manager_get_widget(menu_manager, "/MainMenu"));
+
+ build_sensor_menu_items(ui, menu);
+
return GTK_WIDGET(menu);
}
{
GtkStatusIcon *ico;
- log_debug("ui_appindicator#unity_fallback");
+ log_debug("ui_appindicator.unity_fallback()");
appindicator_supported = 0;
static void
unity_unfallback(AppIndicator *indicator, GtkStatusIcon *status_icon)
{
- log_debug("ui_appindicator#unity_unfallback");
+ log_debug("ui_appindicator.unity_unfallback()");
ui_status_set_visible(0);