static void cpufreq_applet_prefs_show_mode_changed (CPUFreqPrefs *prefs, GParamSpec *arg1, CPUFreqApplet *applet) { cpufreq_applet_update_visibility (applet); }
static void cpufreq_applet_setup (CPUFreqApplet *applet) { GtkActionGroup *action_group; gchar *ui_path; AtkObject *atk_obj; gchar *prefs_key; GSettings *settings; g_set_application_name (_("CPU Frequency Scaling Monitor")); gtk_window_set_default_icon_name ("mate-cpu-frequency-applet"); /* Preferences */ if (applet->prefs) g_object_unref (applet->prefs); settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (applet), "org.mate.panel.applet.cpufreq"); applet->prefs = cpufreq_prefs_new (settings); g_signal_connect (G_OBJECT (applet->prefs), "notify::cpu", G_CALLBACK (cpufreq_applet_prefs_cpu_changed), (gpointer) applet); g_signal_connect (G_OBJECT (applet->prefs), "notify::show-mode", G_CALLBACK (cpufreq_applet_prefs_show_mode_changed), (gpointer) applet); g_signal_connect (G_OBJECT (applet->prefs), "notify::show-text-mode", G_CALLBACK (cpufreq_applet_prefs_show_mode_changed), (gpointer) applet); /* Monitor */ applet->monitor = cpufreq_monitor_factory_create_monitor ( cpufreq_prefs_get_cpu (applet->prefs)); cpufreq_monitor_run (applet->monitor); g_signal_connect_swapped (G_OBJECT (applet->monitor), "changed", G_CALLBACK (cpufreq_applet_update), (gpointer) applet); /* Setup the menus */ action_group = gtk_action_group_new ("CPUFreq Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, cpufreq_applet_menu_actions, G_N_ELEMENTS (cpufreq_applet_menu_actions), applet); ui_path = g_build_filename (CPUFREQ_MENU_UI_DIR, "cpufreq-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet), ui_path, action_group); g_free (ui_path); if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) { GtkAction *action; action = gtk_action_group_get_action (action_group, "CPUFreqPreferences"); gtk_action_set_visible (action, FALSE); } g_object_unref (action_group); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet)); if (GTK_IS_ACCESSIBLE (atk_obj)) { atk_object_set_name (atk_obj, _("CPU Frequency Scaling Monitor")); atk_object_set_description (atk_obj, _("This utility shows the current CPU Frequency")); } cpufreq_applet_update_visibility (applet); gtk_widget_show (GTK_WIDGET (applet)); }
static void cpufreq_applet_setup (CPUFreqApplet *applet) { GSimpleActionGroup *action_group; GAction *action; gchar *ui_path; AtkObject *atk_obj; GSettings *settings; /* Preferences */ if (applet->prefs) g_object_unref (applet->prefs); settings = panel_applet_settings_new (PANEL_APPLET (applet), "org.gnome.gnome-applets.cpufreq"); applet->prefs = cpufreq_prefs_new (settings); g_signal_connect (G_OBJECT (applet->prefs), "notify::cpu", G_CALLBACK (cpufreq_applet_prefs_cpu_changed), (gpointer) applet); g_signal_connect (G_OBJECT (applet->prefs), "notify::show-mode", G_CALLBACK (cpufreq_applet_prefs_show_mode_changed), (gpointer) applet); g_signal_connect (G_OBJECT (applet->prefs), "notify::show-text-mode", G_CALLBACK (cpufreq_applet_prefs_show_mode_changed), (gpointer) applet); /* Monitor */ applet->monitor = cpufreq_monitor_new (cpufreq_prefs_get_cpu (applet->prefs)); cpufreq_monitor_run (applet->monitor); g_signal_connect_swapped (G_OBJECT (applet->monitor), "changed", G_CALLBACK (cpufreq_applet_update), (gpointer) applet); /* Setup the menus */ action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), cpufreq_applet_menu_actions, G_N_ELEMENTS (cpufreq_applet_menu_actions), applet); ui_path = g_build_filename (CPUFREQ_MENU_UI_DIR, "cpufreq-applet-menu.xml", NULL); panel_applet_setup_menu_from_file (PANEL_APPLET (applet), ui_path, action_group, GETTEXT_PACKAGE); g_free (ui_path); gtk_widget_insert_action_group (GTK_WIDGET (applet), "cpufreq", G_ACTION_GROUP (action_group)); action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences"); g_object_bind_property (applet, "locked-down", action, "enabled", G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); g_object_unref (action_group); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet)); if (GTK_IS_ACCESSIBLE (atk_obj)) { atk_object_set_name (atk_obj, _("CPU Frequency Scaling Monitor")); atk_object_set_description (atk_obj, _("This utility shows the current CPU Frequency")); } cpufreq_applet_update_visibility (applet); gtk_widget_show (GTK_WIDGET (applet)); }