static void wireless_applet_load_properties (WirelessApplet *applet) { wireless_applet_set_device (applet, panel_applet_gconf_get_string (PANEL_APPLET (applet), "device", NULL)); /* Oooh, new applet, let's put in the defaults */ if (applet->device == NULL) { applet->device = g_strdup (CFG_DEVICE); applet->show_percent = TRUE; return; } applet->show_percent = panel_applet_gconf_get_bool (PANEL_APPLET (applet), "percent", NULL); }
static void update_finish (WeatherInfo *info, gpointer data) { static int gw_fault_counter = 0; #ifdef HAVE_LIBNOTIFY char *message, *detail; #endif char *s; GWeatherApplet *gw_applet = (GWeatherApplet *)data; gint nxtSunEvent; const gchar *icon_name; /* Update timer */ if (gw_applet->timeout_tag > 0) g_source_remove(gw_applet->timeout_tag); if (gw_applet->gweather_pref.update_enabled) { gw_applet->timeout_tag = g_timeout_add_seconds ( gw_applet->gweather_pref.update_interval, timeout_cb, gw_applet); nxtSunEvent = weather_info_next_sun_event(gw_applet->gweather_info); if (nxtSunEvent >= 0) gw_applet->suncalc_timeout_tag = g_timeout_add_seconds (nxtSunEvent, suncalc_timeout_cb, gw_applet); } if ((TRUE == weather_info_is_valid (info)) || (gw_fault_counter >= MAX_CONSECUTIVE_FAULTS)) { gw_fault_counter = 0; icon_name = weather_info_get_icon_name (gw_applet->gweather_info); gtk_image_set_from_icon_name (GTK_IMAGE(gw_applet->image), icon_name, GTK_ICON_SIZE_BUTTON); gtk_label_set_text (GTK_LABEL (gw_applet->label), weather_info_get_temp_summary( gw_applet->gweather_info)); s = weather_info_get_weather_summary (gw_applet->gweather_info); gtk_widget_set_tooltip_text (GTK_WIDGET (gw_applet->applet), s); g_free (s); /* Update dialog -- if one is present */ if (gw_applet->details_dialog) { gweather_dialog_update (GWEATHER_DIALOG (gw_applet->details_dialog)); } /* update applet */ place_widgets(gw_applet); #ifdef HAVE_LIBNOTIFY if (panel_applet_gconf_get_bool (gw_applet->applet, "show_notifications", NULL)) { NotifyNotification *n; /* Show notifications if possible */ if (!notify_is_initted ()) notify_init (_("Weather Forecast")); if (notify_is_initted ()) { GError *error = NULL; const char *icon; /* Show notification */ message = g_strdup_printf ("%s: %s", weather_info_get_location_name (info), weather_info_get_sky (info)); detail = g_strdup_printf ( _("City: %s\nSky: %s\nTemperature: %s"), weather_info_get_location_name (info), weather_info_get_sky (info), weather_info_get_temp_summary (info)); icon = weather_info_get_icon_name (gw_applet->gweather_info); if (icon == NULL) icon = "stock-unknown"; n = notify_notification_new (message, detail, icon); notify_notification_show (n, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); } g_free (message); g_free (detail); } } #endif } else { /* there has been an error during retrival * just update the fault counter */ gw_fault_counter++; } }
gboolean workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; GError *error; gboolean display_names; BonoboUIComponent* popup_component; panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL); pager = g_new0 (PagerData, 1); pager->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR); setup_gconf (pager); error = NULL; pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error); if (error) { g_printerr (_("Error loading num_rows value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } pager->n_rows = CLAMP (pager->n_rows, 1, MAX_REASONABLE_ROWS); error = NULL; display_names = panel_applet_gconf_get_bool (applet, "display_workspace_names", &error); if (error) { g_printerr (_("Error loading display_workspace_names value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } error = NULL; pager->display_all = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_printerr (_("Error loading display_all_workspaces value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } pager->screen = wncklet_get_screen (pager->applet); /* because the pager doesn't respond to signals at the moment */ wnck_screen_force_update (pager->screen); pager->pager = wnck_pager_new (pager->screen); wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); g_signal_connect (G_OBJECT (pager->pager), "destroy", G_CALLBACK (destroy_pager), pager); pager_update (pager); gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager); gtk_widget_show (pager->pager); gtk_widget_show (pager->applet); g_signal_connect (G_OBJECT (pager->applet), "realize", G_CALLBACK (applet_realized), pager); g_signal_connect (G_OBJECT (pager->applet), "change_orient", G_CALLBACK (applet_change_orient), pager); g_signal_connect (G_OBJECT (pager->applet), "scroll-event", G_CALLBACK (applet_scroll), pager); g_signal_connect (G_OBJECT (pager->applet), "change_background", G_CALLBACK (applet_change_background), pager); panel_applet_set_background_widget (PANEL_APPLET (pager->applet), GTK_WIDGET (pager->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet), NULL, "GNOME_WorkspaceSwitcherApplet.xml", NULL, pager_menu_verbs, pager); if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/PagerPreferences", "hidden", "1", NULL); } popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems"); return TRUE; }
void appconf_load(struct app_t *app) { PanelApplet *applet = app->applet; CfaPreferences *prefs; gchar *s; gint nconds, i; GdkColormap *cmap = gtk_widget_get_colormap(GTK_WIDGET(applet)); prefs = cfa_preferences_new(cmap); s = panel_applet_gconf_get_string(applet, "font_auto", NULL); cfa_preferences_set_font_name(prefs, CFA_DESIGN_FONT_NAME_AUTO, s); g_free(s); s = panel_applet_gconf_get_string(applet,"bg_color_auto", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_BG_COLOR_AUTO, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet,"font_color_auto", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_FONT_COLOR_AUTO, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "arc_color_auto", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_ARC_COLOR_AUTO, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "hand_color_auto", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_HAND_COLOR_AUTO, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "font_manual", NULL); cfa_preferences_set_font_name(prefs, CFA_DESIGN_FONT_NAME_MANUAL, s); g_free(s); s = panel_applet_gconf_get_string(applet,"bg_color_manual", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_BG_COLOR_MANUAL, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet,"font_color_manual", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_FONT_COLOR_MANUAL, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "arc_color_manual", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_ARC_COLOR_MANUAL, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "hand_color_manual", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_HAND_COLOR_MANUAL, cmap, s); g_free(s); s = panel_applet_gconf_get_string(applet, "drag_color_manual", NULL); cfa_preferences_set_color_name(prefs, CFA_DESIGN_DRAG_COLOR_MANUAL, cmap, s); g_free(s); nconds = panel_applet_gconf_get_int(applet, "nconds", NULL); for (i = 0; i < nconds; i++) { gchar key[64]; CfaCond *cond = cfa_cond_new(); gboolean b; gint n; make_cond_key(key, sizeof key, i, "use_cpu"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_use_cpu(cond, b); make_cond_key(key, sizeof key, i, "cpu_id"); n = panel_applet_gconf_get_int(applet, key, NULL); cfa_cond_set_cpu_id(cond, n); make_cond_key(key, sizeof key, i, "use_ac"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_use_ac(cond, b); make_cond_key(key, sizeof key, i, "ac"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_ac(cond, b); make_cond_key(key, sizeof key, i, "use_battery"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_use_battery(cond, b); make_cond_key(key, sizeof key, i, "battery"); s = panel_applet_gconf_get_string(applet, key, NULL); if (s == NULL) s = g_strdup("0-100"); cfa_cond_set_battery(cond, s); g_free(s); make_cond_key(key, sizeof key, i, "use_load"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_use_load(cond, b); make_cond_key(key, sizeof key, i, "load"); s = panel_applet_gconf_get_string(applet, key, NULL); if (s == NULL) s = g_strdup("0-100"); cfa_cond_set_load(cond, s); g_free(s); make_cond_key(key, sizeof key, i, "use_process"); b = panel_applet_gconf_get_bool(applet, key, NULL); cfa_cond_set_use_process(cond, b); make_cond_key(key, sizeof key, i, "process"); s = panel_applet_gconf_get_string(applet, key, NULL); if (s == NULL) s = g_strdup(""); cfa_cond_set_process(cond, s); g_free(s); make_cond_key(key, sizeof key, i, "freq"); s = panel_applet_gconf_get_string(applet, key, NULL); if (s == NULL) s = g_strdup("0"); cfa_cond_set_freq(cond, s); g_free(s); cfa_preferences_add_cond(prefs, cond); } cfa_preferences_set_smooth(prefs, panel_applet_gconf_get_bool(applet, "smooth", NULL)); xlog_debug(1, "appconf_load successful."); app->prefs = prefs; }
void mc_load_preferences (MCData *mc) { GConfValue *history; GError *error = NULL; g_return_if_fail (mc != NULL); g_return_if_fail (PANEL_IS_APPLET (mc->applet)); mc->preferences.show_default_theme = panel_applet_gconf_get_bool (mc->applet, "show_default_theme", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.show_default_theme = MC_DEFAULT_SHOW_DEFAULT_THEME; } mc->preferences.auto_complete_history = panel_applet_gconf_get_bool (mc->applet, "autocomplete_history", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.auto_complete_history = MC_DEFAULT_AUTO_COMPLETE_HISTORY; } mc->preferences.normal_size_x = panel_applet_gconf_get_int (mc->applet, "normal_size_x", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.normal_size_x = MC_DEFAULT_NORMAL_SIZE_X; } mc->preferences.normal_size_x = MAX (mc->preferences.normal_size_x, 50); mc->preferences.normal_size_y = panel_applet_gconf_get_int (mc->applet, "normal_size_y", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.normal_size_y = MC_DEFAULT_NORMAL_SIZE_Y; } mc->preferences.normal_size_y = CLAMP (mc->preferences.normal_size_y, 5, 200); mc->preferences.cmd_line_color_fg_r = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_r", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_fg_r = MC_DEFAULT_CMD_LINE_COLOR_FG_R; } mc->preferences.cmd_line_color_fg_g = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_g", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_fg_g = MC_DEFAULT_CMD_LINE_COLOR_FG_G; } mc->preferences.cmd_line_color_fg_b = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_b", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_fg_b = MC_DEFAULT_CMD_LINE_COLOR_FG_B; } mc->preferences.cmd_line_color_bg_r = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_r", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_bg_r = MC_DEFAULT_CMD_LINE_COLOR_BG_R; } mc->preferences.cmd_line_color_bg_g = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_g", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_bg_g = MC_DEFAULT_CMD_LINE_COLOR_BG_G; } mc->preferences.cmd_line_color_bg_b = panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_b", &error); if (error) { g_error_free (error); error = NULL; mc->preferences.cmd_line_color_bg_b = MC_DEFAULT_CMD_LINE_COLOR_BG_B; } mc->preferences.macros = mc_load_macros (mc); history = panel_applet_gconf_get_value (mc->applet, "history", NULL); if (history) { GSList *l; for (l = gconf_value_get_list (history); l; l = l->next) { const char *entry = NULL; if ((entry = gconf_value_get_string (l->data))) append_history_entry (mc, entry, TRUE); } gconf_value_free (history); } mc_setup_listeners (mc); mc->preferences.idle_macros_loader_id = 0; }
gboolean applet_main (MyPanelApplet *applet_widget, const gchar *iid, gpointer data) { streamer_applet *applet; char *zErrMsg; int res, i; char ui[24576]; if (strcmp (iid, APPLET_ID) != 0) return FALSE; // i18n setlocale (LC_ALL, ""); bindtextdomain (PACKAGE_NAME, LOCALEDIR); bind_textdomain_codeset(PACKAGE_NAME, "utf-8"); textdomain (PACKAGE_NAME); // Init applet = g_malloc0(sizeof(streamer_applet)); applet->applet = applet_widget; memset(&applet->xml_listen_url[0], '\0', 1024); memset(&applet->xml_bitrate[0], '\0', 1024); memset(&applet->xml_server_name[0], '\0', 1024); memset(&applet->xml_genre[0], '\0', 1024); memset(&applet->url[0], '\0', 1024); memset(&applet->ui_fav[0], '\0', 10240); memset(&applet->ui_recent[0], '\0', 10240); applet->timestamp = time(NULL); applet->xml_curr_entries = 0; applet->icecast_total_entries = 0; applet->status = 0; for (i=0; i<10; i++) { memset(&applet->hash_fav[i].hash[0], '\0', 64); memset(&applet->hash_recent[i].hash[0], '\0', 64); } applet->settings.show_notifications = 0; applet->settings.duration_notifications = 5; #ifdef HAVE_GNOME_2 applet->bonobo_counter = 0; #endif // Check home dir, copy skel database char applet_home_dir[1024], skel_file[1024], local_file[1024]; struct stat stat_buf; struct passwd *pw = getpwuid(getuid()); sprintf(&applet_home_dir[0], "%s/%s", pw->pw_dir, APPLET_HOME_DIR); int stat_res = stat(&applet_home_dir[0], &stat_buf); int errsv = errno; if ((stat_res == 0) && (!S_ISDIR(stat_buf.st_mode))){ push_notification(_("Streamer Applet Error"), _("Cannot access configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } else if (stat_res == -1) { if (errsv == ENOENT) { int mkdir_res = mkdir(&applet_home_dir[0], 0755); if (mkdir_res == 1) { push_notification(_("Streamer Applet Error"), _("Cannot create configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } } else { push_notification(_("Streamer Applet Error"), _("Cannot verify configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } } sprintf(&skel_file[0], "%s/%s", APPLET_SKEL_PATH, APPLET_SQLITE_DB_FILENAME); sprintf(&local_file[0], "%s/%s/%s", pw->pw_dir, APPLET_HOME_DIR, APPLET_SQLITE_DB_FILENAME); stat_res = stat(&local_file[0], &stat_buf); errsv = errno; if ((stat_res == 0) && (!S_ISREG(stat_buf.st_mode))){ push_notification(_("Streamer Applet Error"), _("Database file is not a regular file. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); } else if (stat_res == -1) { if (errsv == ENOENT) { if (!cp(&local_file[0], &skel_file[0])) { push_notification(_("Streamer Applet Error"), _("Cannot copy database file to configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } } else { push_notification(_("Streamer Applet Error"), _("Cannot verify database file. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } } // Test DB connection, upgrade DB if necessary if (!sqlite_connect(applet)) { push_notification(_("Streamer Applet Error"), _("Unable to connect to DB. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION); return FALSE; } zErrMsg = 0; res = sqlite3_exec(applet->sqlite, "SELECT version FROM version", cb_sql_version, (void*) applet, &zErrMsg); if (res != SQLITE_OK) { push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION); sqlite3_free(zErrMsg); return FALSE; } if (applet->db_version == 1) { // Upgrade DB to version 2 sqlite_insert(applet, "CREATE TABLE custom_stations (server_name VARCHAR(255), listen_url VARCHAR(255), bitrate VARCHAR(255), genre VARCHAR(255))"); sqlite_insert(applet, "ALTER TABLE stations RENAME TO icecast_stations"); sqlite_insert(applet, "UPDATE version SET version=2"); } else if (applet->db_version == 2) { // Upgrade DB to version 3 sqlite_insert(applet, "CREATE TABLE rbrowser_stations (server_name VARCHAR(255), listen_url VARCHAR(255), bitrate VARCHAR(255), genre VARCHAR(255))"); sqlite_insert(applet, "UPDATE version SET version=3"); } sqlite3_close(applet->sqlite); // Init GStreamer gstreamer_init(applet); // Get an image char image_file[1024]; sprintf(&image_file[0], "%s/%s", APPLET_ICON_PATH, APPLET_ICON_PAUSE); applet->image = gtk_image_new_from_file (&image_file[0]); // Put the image into a container (it needs to receive actions) applet->event_box = gtk_event_box_new(); gtk_container_add (GTK_CONTAINER (applet->event_box), applet->image); // Put the container into the applet gtk_container_add (GTK_CONTAINER (applet->applet), applet->event_box); // Define menu action group #ifdef HAVE_MATE applet->action_group = gtk_action_group_new ("Streamer_Applet_Actions"); gtk_action_group_set_translation_domain(applet->action_group, PACKAGE_NAME); gtk_action_group_add_actions (applet->action_group, applet_menu_actions_mate, G_N_ELEMENTS (applet_menu_actions_mate), applet); #endif // Get last 10 entried from Recent & Fav, then fetch last URL if (!sqlite_connect(applet)) return FALSE; zErrMsg = 0; memset(&applet->ui_recent[0], '\0', 1); res = sqlite3_exec(applet->sqlite, "SELECT server_name, listen_url FROM recent GROUP BY listen_url ORDER BY unix_timestamp DESC LIMIT 10", cb_sql_recent_10, (void*) applet, &zErrMsg); if (res != SQLITE_OK) { push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION); sqlite3_free(zErrMsg); return FALSE; } memset(&applet->ui_fav[0], '\0', 1); res = sqlite3_exec(applet->sqlite, "SELECT server_name, listen_url FROM favourites LIMIT 10", cb_sql_fav_10, (void*) applet, &zErrMsg); if (res != SQLITE_OK) { push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION); sqlite3_free(zErrMsg); return FALSE; } res = sqlite3_exec(applet->sqlite, "SELECT * FROM recent ORDER BY unix_timestamp DESC LIMIT 1", cb_sql_recent, (void*) applet, &zErrMsg); if (res != SQLITE_OK) { push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION); sqlite3_free(zErrMsg); return FALSE; } sqlite3_free(zErrMsg); sqlite3_close(applet->sqlite); // Build menu sprintf(&ui[0], "%s %s %s %s %s", ui1, &applet->ui_recent[0], ui2, &applet->ui_fav[0], ui3); #ifdef HAVE_MATE mate_panel_applet_setup_menu(applet->applet, &ui[0], applet->action_group); #elif HAVE_GNOME_2 BonoboUIVerb bnb1 = BONOBO_UI_UNSAFE_VERB ("All", G_CALLBACK (menu_cb_all)); applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb1; applet->bonobo_counter++; BonoboUIVerb bnb1a = BONOBO_UI_UNSAFE_VERB ("Settings", G_CALLBACK (menu_cb_settings)); applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb1a; applet->bonobo_counter++; BonoboUIVerb bnb2 = BONOBO_UI_UNSAFE_VERB ("About", G_CALLBACK (menu_cb_about)); applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb2; applet->bonobo_counter++; BonoboUIVerb bnb3 = BONOBO_UI_VERB_END; applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb3; applet->bonobo_counter++; panel_applet_setup_menu(applet->applet, &ui[0], applet->applet_menu_actions_gnome, applet); #endif // Merge menu //GError **error; //char ui[10240]; //sprintf(&ui[0], "<menu action='SubMenu1'>\n<menuitem action='All'/>\n<menuitem action='All'/></menu>"); //guint merge_id = gtk_ui_manager_add_ui_from_string (applet->applet->priv->ui_manager, &ui[0], -1, error); // Settings: Prepare DConf - GNOME2 only #ifdef HAVE_GNOME_2 if (!panel_applet_gconf_get_bool(PANEL_APPLET(applet->applet), "have_settings", NULL)) { panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "have_settings", TRUE, NULL); panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_1, 0, NULL); panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_2, 5, NULL); } #endif // Load settings #ifdef HAVE_MATE applet->gsettings = g_settings_new_with_path(APPLET_GSETTINGS_SCHEMA, APPLET_GSETTINGS_PATH); applet->settings.show_notifications = g_settings_get_int(applet->gsettings, APPLET_KEY_OPTION_1); applet->settings.duration_notifications = g_settings_get_int(applet->gsettings, APPLET_KEY_OPTION_2); #elif HAVE_GNOME_2 applet->settings.show_notifications = panel_applet_gconf_get_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_1, NULL); applet->settings.duration_notifications = panel_applet_gconf_get_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_2, NULL); #endif // Signals g_signal_connect(G_OBJECT(applet->event_box), "button_press_event", G_CALLBACK (on_left_click), (gpointer)applet); g_signal_connect(G_OBJECT(applet->applet), "change_background", G_CALLBACK (applet_back_change), (gpointer)applet); g_signal_connect(G_OBJECT(applet->applet), "destroy", G_CALLBACK(applet_destroy), (gpointer)applet); // Tooltip gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), _("No stream selected. Right-click to load one.")); // Show applet gtk_widget_show_all (GTK_WIDGET (applet->applet)); // Run applet->loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (applet->loop); return TRUE; }
gboolean window_list_applet_fill (PanelApplet *applet) { TasklistData *tasklist; GError *error; GConfValue *value; gint sizepref; tasklist = g_new0 (TasklistData, 1); tasklist->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (tasklist->applet), PANEL_APPLET_EXPAND_MAJOR | PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE); panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL); setup_gconf (tasklist); error = NULL; tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_error_free (error); tasklist->include_all_workspaces = FALSE; /* Default value */ } error = NULL; tasklist->grouping = -1; value = panel_applet_gconf_get_value (applet, "group_windows", &error); if (error) { g_error_free (error); } else if (value) { tasklist->grouping = get_grouping_type (value); gconf_value_free (value); } if (tasklist->grouping < 0) tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */ error = NULL; tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error); if (error) { g_error_free (error); tasklist->move_unminimized_windows = TRUE; /* Default value */ } tasklist->size = panel_applet_get_size (applet); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } tasklist->screen = wncklet_get_screen (tasklist->applet); /* because the tasklist doesn't respond to signals at the moment */ wnck_screen_force_update (tasklist->screen); tasklist->tasklist = wnck_tasklist_new (tasklist->screen); wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist), icon_loader_func, tasklist, NULL); /* get size preferences */ error = NULL; sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error); if (error) { sizepref = 50; /* Default value */ g_error_free (error); } if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref); else wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref); error = NULL; sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error); if (error) { sizepref = 4096; /* Default value */ g_error_free (error); } tasklist->maximum_size = sizepref; g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy", G_CALLBACK (destroy_tasklist), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "size_request", G_CALLBACK (applet_size_request), tasklist); tasklist_update (tasklist); gtk_widget_show (tasklist->tasklist); gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "realize", G_CALLBACK (applet_realized), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_orient", G_CALLBACK (applet_change_orient), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_size", G_CALLBACK (applet_change_pixel_size), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_background", G_CALLBACK (applet_change_background), tasklist); panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet), GTK_WIDGET (tasklist->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet), NULL, "GNOME_WindowListApplet.xml", NULL, tasklist_menu_verbs, tasklist); if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/TasklistPreferences", "hidden", "1", NULL); } gtk_widget_show (tasklist->applet); return TRUE; }