static void wckbuttons_read (WBPlugin *wb) { XfceRc *rc; gchar *file; const gchar *button_layout, *theme; /* allocate memory for the preferences structure */ wb->prefs = g_slice_new0(WBPreferences); /* get the plugin config file location */ file = xfce_panel_plugin_save_location (wb->plugin, TRUE); if (G_LIKELY (file != NULL)) { /* open the config file, readonly */ rc = xfce_rc_simple_open (file, TRUE); /* cleanup */ g_free (file); if (G_LIKELY (rc != NULL)) { /* read the settings */ wb->prefs->only_maximized = xfce_rc_read_bool_entry(rc, "only_maximized", DEFAULT_ONLY_MAXIMIZED); wb->prefs->show_on_desktop = xfce_rc_read_bool_entry(rc, "show_on_desktop", DEFAULT_SHOW_ON_DESKTOP); wb->prefs->sync_wm_theme = xfce_rc_read_bool_entry(rc, "sync_wm_theme", DEFAULT_SYNC_WM_THEME); button_layout = xfce_rc_read_entry (rc, "button_layout", DEFAULT_BUTTON_LAYOUT); wb->prefs->button_layout = button_layout_filter (button_layout, DEFAULT_BUTTON_LAYOUT); theme = xfce_rc_read_entry (rc, "theme", DEFAULT_THEME); wb->prefs->theme = g_strdup (theme); wb->prefs->inactive_text_alpha = xfce_rc_read_int_entry (rc, "inactive_text_alpha", DEFAULT_INACTIVE_TEXT_ALPHA); wb->prefs->inactive_text_shade = xfce_rc_read_int_entry (rc, "inactive_text_shade", DEFAULT_INACTIVE_TEXT_SHADE); /* cleanup */ xfce_rc_close (rc); /* leave the function, everything went well */ return; } } /* something went wrong, apply default values */ DBG ("Applying default settings"); wb->prefs->only_maximized = DEFAULT_ONLY_MAXIMIZED; wb->prefs->show_on_desktop = DEFAULT_SHOW_ON_DESKTOP; wb->prefs->sync_wm_theme = DEFAULT_SYNC_WM_THEME; wb->prefs->button_layout = DEFAULT_BUTTON_LAYOUT; wb->prefs->theme = DEFAULT_THEME; wb->prefs->inactive_text_alpha = DEFAULT_INACTIVE_TEXT_ALPHA; wb->prefs->inactive_text_shade = DEFAULT_INACTIVE_TEXT_SHADE; }
static void macmenu_load_from_rc(MacMenu* mmb) { char* file; if (!(file = xfce_panel_plugin_lookup_rc_file(mmb->applet))) return; XfceRc* rc = xfce_rc_simple_open(file, TRUE); g_free(file); if (!rc) return; mmb->hide_label = xfce_rc_read_bool_entry(rc, "HideLabel", FALSE); xfce_rc_close (rc); }
static void migrate_46_plugin_heartlenv_menu (XfconfChannel *channel, XfceRc *rc) { migrate_46_plugin_bool ("show_menu_icons", "show-menu-icons", TRUE); migrate_46_plugin_bool ("show_button_title", "show-button-title", TRUE); migrate_46_plugin_string ("menu_file", "custom-menu-file", ""); migrate_46_plugin_string ("icon_file", "button-icon", "heartlenv-panel-menu"); migrate_46_plugin_string ("button_title", "button-title", ""); if (xfce_rc_has_entry (rc, "use_default_menu")) xfconf_channel_set_bool (channel, "/custom-menu", !xfce_rc_read_bool_entry (rc, "use_default_menu", TRUE)); }
static gboolean read_entry_bool (const gchar *entry, gboolean fallback) { gboolean ret_val = fallback; gchar *file; XfceRc *rc; file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, RESOURCE_FILE, TRUE); rc = xfce_rc_simple_open (file, TRUE); g_free (file); if ( rc ) { ret_val = xfce_rc_read_bool_entry (rc, entry, fallback); xfce_rc_close (rc); } return ret_val; }
void sm_init (XfceRc *rc, gboolean disable_tcp) { char *network_idlist; char error[2048]; if (disable_tcp || xfce_rc_read_bool_entry (rc, "DisableTcp", FALSE)) { #ifdef HAVE__ICETRANSNOLISTEN extern void _IceTransNoListen (char *protocol); _IceTransNoListen ("tcp"); #else if (G_UNLIKELY (verbose)) { fprintf (stderr, "xfce4-session: Requested to disable tcp connections, but " "_IceTransNoListen is not available on this plattform. " "Request will be ignored.\n"); } #endif } if (!SmsInitialize (PACKAGE, VERSION, sm_new_client, NULL, ice_auth_proc, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to register XSM protocol: %s\n", error); exit (EXIT_FAILURE); } if (!IceListenForConnections (&num_listeners, &listen_objs, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to establish ICE listeners: %s\n", error); exit (EXIT_FAILURE); } ice_setup_listeners (num_listeners, listen_objs); network_idlist = IceComposeNetworkIdList (num_listeners, listen_objs); xfce_setenv ("SESSION_MANAGER", network_idlist, TRUE); free (network_idlist); }
static void sample_read (SamplePlugin *sample) { XfceRc *rc; gchar *file; const gchar *value; /* get the plugin config file location */ file = xfce_panel_plugin_save_location (sample->plugin, TRUE); if (G_LIKELY (file != NULL)) { /* open the config file, readonly */ rc = xfce_rc_simple_open (file, TRUE); /* cleanup */ g_free (file); if (G_LIKELY (rc != NULL)) { /* read the settings */ value = xfce_rc_read_entry (rc, "setting1", DEFAULT_SETTING1); sample->setting1 = g_strdup (value); sample->setting2 = xfce_rc_read_int_entry (rc, "setting2", DEFAULT_SETTING2); sample->setting3 = xfce_rc_read_bool_entry (rc, "setting3", DEFAULT_SETTING3); /* cleanup */ xfce_rc_close (rc); /* leave the function, everything went well */ return; } } /* something went wrong, apply default values */ DBG ("Applying default settings"); sample->setting1 = g_strdup (DEFAULT_SETTING1); sample->setting2 = DEFAULT_SETTING2; sample->setting3 = DEFAULT_SETTING3; }
static void migrate_46_plugin_launcher (XfconfChannel *channel, XfceRc *rc, guint plugin_id, GError **error) { guint i; gchar buf[128]; XfceRc *new_desktop; gchar *path; GTimeVal timeval; GPtrArray *array; GValue *value; gchar *filename; if (xfce_rc_has_group (rc, "Global")) { xfce_rc_set_group (rc, "Global"); migrate_46_plugin_bool ("MoveFirst", "move-first", FALSE); migrate_46_plugin_bool ("ArrowPosition", "arrow-position", 0); } g_get_current_time (&timeval); array = g_ptr_array_new (); for (i = 0; i < 100 /* arbitrary */; i++) { g_snprintf (buf, sizeof (buf), "Entry %d", i); if (!xfce_rc_has_group (rc, buf)) break; xfce_rc_set_group (rc, buf); g_snprintf (buf, sizeof (buf), "heartlenv" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S LAUNCHER_FOLDER "-%d" G_DIR_SEPARATOR_S "%ld%d.desktop", plugin_id, timeval.tv_sec, i); path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, buf, TRUE); if (G_UNLIKELY (path == NULL)) { g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR, "Failed to create new launcher desktop file in \"%s\"", buf); break; } else if (g_file_test (path, G_FILE_TEST_EXISTS)) { g_set_error (error, G_FILE_ERROR_EXIST, G_FILE_ERROR, "Deasktop item \"%s\" already exists", path); g_free (path); break; } new_desktop = xfce_rc_simple_open (path, FALSE); if (G_UNLIKELY (new_desktop == NULL)) { g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR, "Failed to create new desktop file \"%s\"", path); g_free (path); break; } xfce_rc_set_group (new_desktop, G_KEY_FILE_DESKTOP_GROUP); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TYPE, G_KEY_FILE_DESKTOP_TYPE_APPLICATION); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_NAME, xfce_rc_read_entry (rc, "Name", "")); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_COMMENT, xfce_rc_read_entry (rc, "Comment", "")); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_ICON, xfce_rc_read_entry (rc, "Icon", "")); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_EXEC, xfce_rc_read_entry (rc, "Exec", "")); xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_PATH, xfce_rc_read_entry (rc, "Path", "")); xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TERMINAL, xfce_rc_read_bool_entry (rc, "Terminal", FALSE)); xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE)); xfce_rc_flush (new_desktop); if (xfce_rc_is_dirty (new_desktop)) { g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR, "Failed to flush desktop file \"%s\"", path); g_free (path); xfce_rc_close (new_desktop); break; } g_free (path); xfce_rc_close (new_desktop); value = g_new0 (GValue, 1); g_value_init (value, G_TYPE_STRING); filename = g_strdup_printf ("%ld%d.desktop", timeval.tv_sec, i); g_value_take_string (value, filename); g_ptr_array_add (array, value); } xfconf_channel_set_arrayv (channel, "/items", array); xfconf_array_free (array); }
static void windowck_read(WindowckPlugin *wckp) { XfceRc *rc; gchar *file; const gchar *title_font; /* allocate memory for the preferences structure */ wckp->prefs = g_slice_new0(WCKPreferences); /* get the plugin config file location */ file = xfce_panel_plugin_save_location(wckp->plugin, TRUE); if (G_LIKELY (file != NULL)) { /* open the config file, readonly */ rc = xfce_rc_simple_open(file, TRUE); /* cleanup */ g_free(file); if (G_LIKELY (rc != NULL)) { /* read the settings */ wckp->prefs->only_maximized = xfce_rc_read_bool_entry(rc, "only_maximized", DEFAULT_ONLY_MAXIMIZED); wckp->prefs->show_on_desktop = xfce_rc_read_bool_entry(rc, "show_on_desktop", DEFAULT_SHOW_ON_DESKTOP); wckp->prefs->show_icon = xfce_rc_read_bool_entry(rc, "show_icon", DEFAULT_SHOW_ICON); wckp->prefs->icon_on_right = xfce_rc_read_bool_entry(rc, "icon_on_right", DEFAULT_ICON_ON_RIGHT); wckp->prefs->show_window_menu = xfce_rc_read_bool_entry(rc, "show_window_menu", DEFAULT_SHOW_WINDOW_MENU); wckp->prefs->hide_title = xfce_rc_read_bool_entry(rc, "hide_title", DEFAULT_HIDE_TITLE); wckp->prefs->full_name = xfce_rc_read_bool_entry(rc, "full_name", DEFAULT_FULL_NAME); wckp->prefs->show_tooltips = xfce_rc_read_bool_entry(rc, "show_tooltips", DEFAULT_SHOW_TOOLTIPS); wckp->prefs->size_mode = xfce_rc_read_int_entry (rc, "size_mode", DEFAULT_SIZE_MODE); wckp->prefs->title_size = xfce_rc_read_int_entry(rc, "title_size", DEFAULT_TITLE_SIZE); wckp->prefs->custom_font = xfce_rc_read_bool_entry(rc, "custom_font", DEFAULT_CUSTOM_FONT); title_font = xfce_rc_read_entry(rc, "title_font", DEFAULT_TITLE_FONT); wckp->prefs->title_font = g_strdup(title_font); wckp->prefs->title_alignment = xfce_rc_read_int_entry(rc, "title_alignment", DEFAULT_TITLE_ALIGNMENT); wckp->prefs->title_padding = xfce_rc_read_int_entry(rc, "title_padding", DEFAULT_TITLE_PADDING); /* cleanup */ xfce_rc_close(rc); /* leave the function, everything went well */ return; } } /* something went wrong, apply default values */ DBG("Applying default settings"); wckp->prefs->only_maximized = DEFAULT_ONLY_MAXIMIZED; wckp->prefs->show_on_desktop = DEFAULT_SHOW_ON_DESKTOP; wckp->prefs->show_icon = DEFAULT_SHOW_ICON; wckp->prefs->icon_on_right = DEFAULT_ICON_ON_RIGHT; wckp->prefs->show_window_menu = DEFAULT_SHOW_WINDOW_MENU; wckp->prefs->hide_title = DEFAULT_HIDE_TITLE; wckp->prefs->full_name = DEFAULT_FULL_NAME; wckp->prefs->show_tooltips = DEFAULT_SHOW_TOOLTIPS; wckp->prefs->size_mode = DEFAULT_SIZE_MODE; wckp->prefs->title_size = DEFAULT_TITLE_SIZE; wckp->prefs->custom_font = DEFAULT_CUSTOM_FONT; wckp->prefs->title_font = DEFAULT_TITLE_FONT; wckp->prefs->title_alignment = DEFAULT_TITLE_ALIGNMENT; wckp->prefs->title_padding = DEFAULT_TITLE_PADDING; }
static void initialize (int argc, char **argv) { gboolean disable_tcp = FALSE; GdkDisplay *dpy; XfceRc *rc; for (++argv; --argc > 0; ++argv) { if (strcmp (*argv, "--version") == 0) { printf ("%s (Xfce %s)\n\n" "Copyright (c) 2003-2006\n" " The Xfce development team. All rights reserved.\n\n" "Written for Xfce by Benedikt Meurer <*****@*****.**>.\n\n" "Built with Gtk+-%d.%d.%d, running with Gtk+-%d.%d.%d.\n\n" "Please report bugs to <%s>.\n", PACKAGE_STRING, xfce_version_string (), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version, PACKAGE_BUGREPORT); exit (EXIT_SUCCESS); } else if (strcmp (*argv, "--disable-tcp") == 0) { disable_tcp = TRUE; } else { usage (strcmp (*argv, "--help") == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } } setup_environment (); rc = xfsm_open_config (TRUE); dpy = gdk_display_get_default (); init_display (dpy, rc, disable_tcp); /* verify that the DNS settings are ok */ xfsm_splash_screen_next (splash_screen, _("Verifying DNS settings")); xfsm_dns_check (); xfsm_splash_screen_next (splash_screen, _("Loading session data")); xfce_rc_set_group (rc, "Compatibility"); compat_gnome = xfce_rc_read_bool_entry (rc, "LaunchGnome", FALSE); compat_kde = xfce_rc_read_bool_entry (rc, "LaunchKDE", FALSE); xfce_rc_set_group (rc, "General"); xfsm_startup_init (rc); xfsm_manager_init (rc); /* cleanup obsolete entries */ xfce_rc_set_group (rc, "General"); if (xfce_rc_has_entry (rc, "ConfirmLogout")) xfce_rc_delete_entry (rc, "ConfirmLogout", FALSE); if (xfce_rc_has_entry (rc, "AlwaysDisplayChooser")) xfce_rc_delete_entry (rc, "AlwaysDisplayChooser", FALSE); xfce_rc_delete_group (rc, "Splash Theme", FALSE); xfce_rc_close (rc); }
/** * xfce_dialog_show_help_with_version: * @parent : (allow-none): transient parent of the dialog, or %NULL. * @component : (allow-none): name of the component opening the help page or %NULL. If the * value is %NULL the target will be the main page of the * documentation website. * @page : (allow-none): subpage of the @component on the website or %NULL. * @offset : (allow-none): anchor offset in @page or %NULL. * @version : (allow-none): alternative version, or %NULL to use xfce_version_string(). * * Asks the user to visit the online documentation. If confirmed, it will open * the webbrowser and redirect the user to the correct location. * * Appart from the @component, @page and @offset the following information * is also send to the server: user language and the xfce_version_string() * or @version if set. * * See also: xfce_dialog_show_help(). * * Since: 4.12 * */ void xfce_dialog_show_help_with_version (GtkWindow *parent, const gchar *component, const gchar *page, const gchar *offset, const gchar *version) { GtkWidget *dialog; const gchar *name; gchar *primary; GString *uri; gchar *locale; GtkWidget *message_box; GtkWidget *button; XfceRc *rc; gboolean auto_online; GdkScreen *screen; g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent)); /* get the user's locale without encoding */ locale = g_strdup (setlocale (LC_MESSAGES, NULL)); if (G_LIKELY (locale != NULL)) locale = g_strdelimit (locale, ".", '\0'); else locale = g_strdup ("C"); /* use desktop version if none is set */ if (version == NULL) version = xfce_version_string (); /* build the redirect uri */ uri = g_string_new (MANUAL_WEBSITE); g_string_append_printf (uri, "?version=%s&locale=%s", version, locale); g_free (locale); if (component != NULL) g_string_append_printf (uri, "&component=%s", component); if (page != NULL) g_string_append_printf (uri, "&page=%s", page); if (offset != NULL) g_string_append_printf (uri, "&offset=%s", offset); /* check if we should automatically go online */ rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/help.rc", TRUE); if (rc != NULL) { auto_online = xfce_rc_read_bool_entry (rc, "auto-online", FALSE); xfce_rc_close (rc); if (auto_online) { if (parent != NULL) screen = gtk_window_get_screen (GTK_WINDOW (parent)); else screen = xfce_gdk_screen_get_active (NULL); xfce_dialog_show_help_uri (screen, parent, uri); g_string_free (uri, TRUE); return; } } /* try to get a translated name of the application */ name = g_get_application_name (); if (g_strcmp0 (name, g_get_prgname ()) == 0) name = NULL; /* try to get a decent primary text */ if (name != NULL) primary = g_strdup_printf (_("Do you want to read the %s manual online?"), name); else primary = g_strdup (_("Do you want to read the manual online?")); dialog = xfce_message_dialog_new (parent, _("Online Documentation"), #if !GTK_CHECK_VERSION (3, 10, 0) GTK_STOCK_DIALOG_QUESTION, #else "dialog-question", #endif primary, _("You will be redirected to the documentation website " "where the help pages are maintained and translated."), #if !GTK_CHECK_VERSION (3, 10, 0) GTK_STOCK_CANCEL, #else "gtk-cancel", #endif GTK_RESPONSE_NO, XFCE_BUTTON_TYPE_MIXED, #if !GTK_CHECK_VERSION (3, 10, 0) GTK_STOCK_HELP, #else "help-browser", #endif _("_Read Online"), GTK_RESPONSE_YES, NULL); g_free (primary); message_box = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); g_return_if_fail (GTK_IS_BOX (message_box)); button = gtk_check_button_new_with_mnemonic (_("_Always go directly to the online documentation")); gtk_box_pack_end (GTK_BOX (message_box), button, FALSE, TRUE, 0); #if GTK_CHECK_VERSION (3, 0, 0) g_object_set (G_OBJECT (button), "halign", GTK_ALIGN_END, "margin-start", 8, "margin-end", 8, NULL); gtk_widget_set_hexpand (button, TRUE); #endif g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (xfce_dialog_show_help_auto_toggled), NULL); gtk_widget_show (button); /* don't focus the checkbutton */ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); gtk_widget_grab_focus (button); /* show the dialog without locking the mainloop */ gtk_window_set_modal (GTK_WINDOW (dialog), parent != NULL); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (xfce_dialog_show_help_response), uri); gtk_window_present (GTK_WINDOW (dialog)); }
static void clipman_read (ClipmanPlugin *clipman) { XfceRc *rc; gchar *file; guint type, i, clipslen; gchar name[13]; const gchar *value; /* Because Clipman is unique, we use 1 config file */ /* file = xfce_panel_plugin_save_location (clipman->plugin, FALSE); DBG("Read from file: %s", file); */ file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE); if (G_UNLIKELY (!file)) return; rc = xfce_rc_simple_open (file, FALSE); g_free (file); xfce_rc_set_group (rc, "Properties"); clipman->ExitSave = xfce_rc_read_bool_entry (rc, "ExitSave", DEFEXITSAVE); clipman->IgnoreSelect = xfce_rc_read_bool_entry (rc, "IgnoreSelect", DEFIGNORESELECT); clipman->PreventEmpty = xfce_rc_read_bool_entry (rc, "PreventEmpty", DEFPREVENTEMPTY); switch (xfce_rc_read_int_entry (rc, "Behaviour", DEFBEHAVIOUR)) { case 1: clipman->Behaviour = NORMAL; DBG ("Behaviour = NORMAL"); break; case 2: clipman->Behaviour = STRICTLY; DBG ("Behaviour = STRICTLY"); break; } clipman->ItemNumbers = xfce_rc_read_bool_entry (rc, "ItemNumbers", DEFITEMNUMBERS); clipman->SeparateMenu = xfce_rc_read_bool_entry (rc, "SeparateMenu", DEFSEPMENU); clipman->HistoryItems = xfce_rc_read_int_entry (rc, "HistoryItems", DEFHISTORY); clipman->MenuCharacters = xfce_rc_read_int_entry (rc, "MenuCharacters", DEFCHARS); if (clipman->HistoryItems > MAXHISTORY) clipman->HistoryItems = MAXHISTORY; if (clipman->HistoryItems < MINHISTORY) clipman->HistoryItems = MINHISTORY; if (clipman->MenuCharacters > MAXCHARS) clipman->MenuCharacters = MAXCHARS; if (clipman->MenuCharacters < MINCHARS) clipman->MenuCharacters = MINCHARS; xfce_rc_set_group (rc, "Clips"); clipslen = xfce_rc_read_int_entry (rc, "ClipsLen", 0); if (clipslen > MAXHISTORY) clipslen = MAXHISTORY; if (clipman->ExitSave && clipslen > 0 ) { DBG("Restoring the clipboard"); for (i = 0; i < clipslen; ++i) { g_snprintf (name, 13, "clip_%d_text", i); value = xfce_rc_read_entry (rc, name, ""); g_snprintf (name, 13, "clip_%d_from", i); type = xfce_rc_read_int_entry (rc, name, 0); if (type == 0) clipman_add_clip (clipman, (gchar *)value, PRIMARY); else clipman_add_clip (clipman, (gchar *)value, DEFAULT); } } xfce_rc_close (rc); }
static void time_out_load_settings (TimeOutPlugin *time_out) { XfceRc *rc; gchar *filename; /* Default settings */ gint break_countdown_seconds = DEFAULT_BREAK_COUNTDOWN_SECONDS; gint lock_countdown_seconds = DEFAULT_LOCK_COUNTDOWN_SECONDS; gint postpone_countdown_seconds = DEFAULT_POSTPONE_COUNTDOWN_SECONDS; gboolean enabled = DEFAULT_ENABLED; gboolean display_seconds = DEFAULT_DISPLAY_SECONDS; gboolean display_hours = DEFAULT_DISPLAY_HOURS; gboolean display_time = DEFAULT_DISPLAY_TIME; gboolean display_icon = DEFAULT_DISPLAY_ICON; gboolean allow_postpone = DEFAULT_ALLOW_POSTPONE; gboolean auto_resume = DEFAULT_AUTO_RESUME;; g_return_if_fail (time_out != NULL); /* Search for the config file */ filename = xfce_panel_plugin_save_location (time_out->plugin, FALSE); /* Only try to read the file if it exists */ if (G_LIKELY (filename != NULL)) { /* Open file handle */ rc = xfce_rc_simple_open (filename, TRUE); /* Check if the file could be opened */ if (G_LIKELY (rc != NULL)) { /* Read settings */ break_countdown_seconds = xfce_rc_read_int_entry (rc, "break-countdown-seconds", break_countdown_seconds); lock_countdown_seconds = xfce_rc_read_int_entry (rc, "lock-countdown-seconds", lock_countdown_seconds); postpone_countdown_seconds = xfce_rc_read_int_entry (rc, "postpone-countdown-seconds", postpone_countdown_seconds); enabled = xfce_rc_read_bool_entry (rc, "enabled", enabled); display_seconds = xfce_rc_read_bool_entry (rc, "display-seconds", display_seconds); display_hours = xfce_rc_read_bool_entry (rc, "display-hours", display_hours); display_time = xfce_rc_read_bool_entry (rc, "display-time", display_time); display_icon = xfce_rc_read_bool_entry (rc, "display-icon", display_icon); allow_postpone = xfce_rc_read_bool_entry (rc, "allow-postpone", allow_postpone); auto_resume = xfce_rc_read_bool_entry (rc, "auto-resume", auto_resume); /* Close file handle */ xfce_rc_close (rc); } /* Free filename */ g_free (filename); } /* Apply settings */ time_out->break_countdown_seconds = break_countdown_seconds; time_out->lock_countdown_seconds = lock_countdown_seconds; time_out->postpone_countdown_seconds = postpone_countdown_seconds; time_out->enabled = enabled; time_out->display_seconds = display_seconds; time_out->display_hours = display_hours; time_out->display_time = display_time; time_out->display_icon = display_icon; time_out->allow_postpone = allow_postpone; time_out->auto_resume = auto_resume; }
void multiload_ps_settings_get_boolean(gpointer settings, const gchar *key, gboolean *destination) { *destination = xfce_rc_read_bool_entry((XfceRc*)settings, key, *destination); }
static XfaeItem* xfae_item_new (const gchar *relpath) { const gchar *value; XfaeItem *item = NULL; gboolean skip = FALSE; XfceRc *rc; gchar **only_show_in; gchar **not_show_in; gchar **args; gint m; GtkIconTheme *icon_theme; gchar *command; rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, relpath, TRUE); if (G_LIKELY (rc != NULL)) { xfce_rc_set_group (rc, "Desktop Entry"); /* verify that we have an application here */ value = xfce_rc_read_entry (rc, "Type", NULL); if (G_LIKELY (value != NULL && g_ascii_strcasecmp (value, "Application") == 0)) { icon_theme = gtk_icon_theme_get_default (); item = g_new0 (XfaeItem, 1); item->relpath = g_strdup (relpath); value = xfce_rc_read_entry (rc, "Name", NULL); if (G_LIKELY (value != NULL)) item->name = g_strdup (value); value = xfce_rc_read_entry (rc, "Icon", "application-x-executable"); if (G_UNLIKELY (value != NULL)) item->icon = gtk_icon_theme_load_icon (icon_theme, value, 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); value = xfce_rc_read_entry (rc, "Comment", NULL); if (G_LIKELY (value != NULL)) item->comment = g_strdup (value); value = xfce_rc_read_entry (rc, "Exec", NULL); if (G_LIKELY (value != NULL)) item->tooltip = g_markup_printf_escaped ("<b>%s</b> %s", _("Command:"), value); item->hidden = xfce_rc_read_bool_entry (rc, "Hidden", FALSE); } else { return NULL; } item->show_in_override = xfce_rc_read_bool_entry (rc, "X-XFCE-Autostart-Override", FALSE); /* check the NotShowIn setting */ not_show_in = xfce_rc_read_list_entry (rc, "NotShowIn", ";"); if (G_UNLIKELY (not_show_in != NULL)) { /* check if "XFCE" is specified */ for (m = 0; not_show_in[m] != NULL; ++m) if (g_ascii_strcasecmp (not_show_in[m], "XFCE") == 0) { skip = TRUE; break; } g_strfreev (not_show_in); } /* check the OnlyShowIn setting */ only_show_in = xfce_rc_read_list_entry (rc, "OnlyShowIn", ";"); if (G_UNLIKELY (only_show_in != NULL)) { /* check if "XFCE" is specified */ for (m = 0; only_show_in[m] != NULL; ++m) if (g_ascii_strcasecmp (only_show_in[m], "XFCE") == 0) { item->show_in_xfce = TRUE; break; } g_strfreev (only_show_in); } else { /* no OnlyShowIn, treat it like a normal application */ item->show_in_xfce = TRUE; } value = xfce_rc_read_entry (rc, "TryExec", NULL); if (value != NULL && g_shell_parse_argv (value, NULL, &args, NULL)) { if (!g_file_test (args[0], G_FILE_TEST_EXISTS)) { command = g_find_program_in_path (args[0]); if (command == NULL) skip = TRUE; g_free (command); } g_strfreev (args); } xfce_rc_close (rc); /* check if we should skip the item */ if (G_UNLIKELY (skip)) { xfae_item_free (item); item = NULL; } } return item; }
Plugin::Plugin(XfcePanelPlugin *xfce_plugin_) : xfce_plugin(xfce_plugin_), // Setting defaults icon_path("/usr/share/pixmaps/xfce4-hardware-monitor-plugin.png"), viewer_type("curve"), viewer_font(""), viewer_size(96), // Arbitrary default, see later in this function for notes background_color(0x000000FF), // Black as the night - note that the // transparency bits need to be set to max to // ensure the colour is visible use_background_color(false), next_color(0), viewer_text_overlay_enabled(false), viewer_text_overlay_format_string("%a %m"), viewer_text_overlay_separator(" "), viewer_text_overlay_font(""), viewer_text_overlay_use_font(false), viewer_text_overlay_color(0x000000FF), viewer_text_overlay_position(CanvasView::top_left), viewer_monitor_type_sync_enabled(true) { // Search for settings file XfceRc* settings_ro = NULL; gchar* file = xfce_panel_plugin_lookup_rc_file(xfce_plugin); if (file) { // One exists - loading settings settings_ro = xfce_rc_simple_open(file, true); g_free(file); // Ensuring default group is in focus xfce_rc_set_group(settings_ro, NULL); icon_path = xfce_rc_read_entry(settings_ro, "icon-path", icon_path.c_str()); viewer_type = xfce_rc_read_entry(settings_ro, "viewer_type", viewer_type.c_str()); viewer_size = xfce_rc_read_int_entry(settings_ro, "viewer_size", viewer_size); viewer_font = xfce_rc_read_entry(settings_ro, "viewer_font", viewer_font.c_str()); background_color = xfce_rc_read_int_entry(settings_ro, "background_color", background_color); use_background_color = xfce_rc_read_bool_entry(settings_ro, "use_background_color", use_background_color); next_color = xfce_rc_read_int_entry(settings_ro, "next_color", next_color); viewer_text_overlay_enabled = xfce_rc_read_bool_entry(settings_ro, "viewer_text_overlay_enabled", viewer_text_overlay_enabled); viewer_text_overlay_format_string = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_format_string", viewer_text_overlay_format_string.c_str()); viewer_text_overlay_separator = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_separator", viewer_text_overlay_separator.c_str()); viewer_text_overlay_font = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_font", viewer_text_overlay_font.c_str()); viewer_text_overlay_color = xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_color", viewer_text_overlay_color); viewer_monitor_type_sync_enabled = xfce_rc_read_bool_entry(settings_ro, "viewer_monitor_type_sync_enabled", viewer_monitor_type_sync_enabled); // Enum is validated in set_viewer_text_overlay_position CanvasView::TextOverlayPosition text_overlay_position = static_cast<CanvasView::TextOverlayPosition>( xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_position", CanvasView::top_left)); set_viewer_text_overlay_position(text_overlay_position); } // Loading icon try { icon = Gdk::Pixbuf::create_from_file(icon_path); } catch (...) { std::cerr << String::ucompose(_("Hardware Monitor: cannot load the icon '%1'.\n"), icon_path); // It's a minor problem if we can't find the icon icon = Glib::RefPtr<Gdk::Pixbuf>(); } // Configuring viewer type viewer_type_listener(viewer_type); /* Actually setting the viewer size has no effect in this function - * seems that it needs to be done in or after the mainloop kicks off */ // Loading up monitors /* Plugin& is initialised from non-transient address of this ('this' itself * is an rvalue so not allowed for a reference) */ monitor_seq mon = load_monitors(settings_ro, *this); for (monitor_iter i = mon.begin(), end = mon.end(); i != end; ++i) add_monitor(*i); // All settings loaded if (settings_ro) xfce_rc_close(settings_ro); /* Connect plugin signals to functions - since I'm not really interested * in the plugin but the plugin pointer, swapped results in the signal * handler getting the plugin reference first - the plugin pointer is * passed next, but since the handler only takes one parameter this is * discarded * Providing About option */ g_signal_connect_swapped(xfce_plugin, "about", G_CALLBACK(display_about), this); // Hooking into Properties option g_signal_connect_swapped(xfce_plugin, "configure-plugin", G_CALLBACK(display_preferences), this); // Hooking into plugin destruction signal g_signal_connect_swapped(xfce_plugin, "free-data", G_CALLBACK(plugin_free), this); // Hooking into save signal g_signal_connect_swapped(xfce_plugin, "save", G_CALLBACK(save_monitors), this); /* Not needed as the canvas resizes on the fly // Hooking into size changed signal g_signal_connect(xfce_plugin, "size-changed", G_CALLBACK(size_changed), this); */ // Adding configure and about to the plugin's right-click menu xfce_panel_plugin_menu_show_configure(xfce_plugin); xfce_panel_plugin_menu_show_about(xfce_plugin); /* Add plugin to panel - I need to turn the Plugin (which inherits from * Gtk::EventBox) into a GtkWidget* - to do this I get at the GObject * pointer underneath the gtkmm layer */ gtk_container_add(GTK_CONTAINER(xfce_plugin), GTK_WIDGET(this->gobj())); // Initialising timer to run every second (by default) to trigger main_loop timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Plugin::main_loop), update_interval); // Initial main_loop run main_loop(); }