void UpdateGSSettings() { auto* s = settings_instance; s->lock_on_blank = g_settings_get_boolean(gs_settings_, LOCK_ENABLED.c_str()) != FALSE; s->lock_on_suspend = g_settings_get_boolean(gs_settings_, LOCK_ON_SUSPEND.c_str()) != FALSE; s->lock_delay = g_settings_get_uint(gs_settings_, LOCK_DELAY.c_str()); }
static void gsd_ldsm_get_config (void) { gchar **settings_list; free_percent_notify = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_KEY); free_percent_notify_again = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_AGAIN_KEY); free_size_gb_no_notify = g_settings_get_int (settings, SETTINGS_FREE_SIZE_NO_NOTIFY); min_notify_period = g_settings_get_int (settings, SETTINGS_MIN_NOTIFY_PERIOD); if (ignore_paths != NULL) { g_slist_foreach (ignore_paths, (GFunc) g_free, NULL); g_clear_pointer (&ignore_paths, g_slist_free); } settings_list = g_settings_get_strv (settings, SETTINGS_IGNORE_PATHS); if (settings_list != NULL) { guint i; for (i = 0; settings_list[i] != NULL; i++) ignore_paths = g_slist_prepend (ignore_paths, g_strdup (settings_list[i])); /* Make sure we dont leave stale entries in ldsm_notified_hash */ g_hash_table_foreach_remove (ldsm_notified_hash, ldsm_is_hash_item_in_ignore_paths, NULL); g_strfreev (settings_list); } purge_trash = g_settings_get_boolean (privacy_settings, SETTINGS_PURGE_TRASH); purge_temp_files = g_settings_get_boolean (privacy_settings, SETTINGS_PURGE_TEMP_FILES); purge_after = g_settings_get_uint (privacy_settings, SETTINGS_PURGE_AFTER); }
static void update_configuration (GtkTreeModel *model) { GtkTreeIter iter; gchar *type; gchar *id; GVariantBuilder builder; GVariant *old_sources; const gchar *old_current_type; const gchar *old_current_id; guint old_current_index; guint old_n_sources; guint index; old_sources = g_settings_get_value (input_sources_settings, KEY_INPUT_SOURCES); old_current_index = g_settings_get_uint (input_sources_settings, KEY_CURRENT_INPUT_SOURCE); old_n_sources = g_variant_n_children (old_sources); if (old_n_sources > 0 && old_current_index < old_n_sources) { g_variant_get_child (old_sources, old_current_index, "(&s&s)", &old_current_type, &old_current_id); } else { old_current_type = ""; old_current_id = ""; } g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)")); index = 0; gtk_tree_model_get_iter_first (model, &iter); do { gtk_tree_model_get (model, &iter, TYPE_COLUMN, &type, ID_COLUMN, &id, -1); if (index != old_current_index && g_str_equal (type, old_current_type) && g_str_equal (id, old_current_id)) { g_settings_set_uint (input_sources_settings, KEY_CURRENT_INPUT_SOURCE, index); } g_variant_builder_add (&builder, "(ss)", type, id); g_free (type); g_free (id); index += 1; } while (gtk_tree_model_iter_next (model, &iter)); g_settings_set_value (input_sources_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder)); g_settings_apply (input_sources_settings); g_variant_unref (old_sources); }
static int get_output_scale (MetaMonitorManager *manager, MetaOutput *output) { MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (manager); int scale = g_settings_get_uint (manager_kms->desktop_settings, "scaling-factor"); if (scale > 0) return scale; else return compute_scale (output); }
static void on_config_tab_width_changed(GSettings *settings, const char *key) { unsigned newvalue = g_settings_get_uint(settings, key); /* Use default if set to 0, as per schema description */ if(newvalue == 0) newvalue = DEFAULT_TAB_WIDTH; /* update application to reflect new value */ I7App *theapp = i7_app_get(); update_tabs(theapp->prefs->tab_example); update_tabs(theapp->prefs->source_example); i7_app_foreach_document(theapp, (I7DocumentForeachFunc)i7_document_update_tabs, NULL); }
static void maybe_migrate_settings (TerminalApp *app) { #ifdef ENABLE_MIGRATION const char * const argv[] = { TERM_LIBEXECDIR "/gnome-terminal-migration", #ifdef ENABLE_DEBUG "--verbose", #endif NULL }; int status; gs_free_error GError *error = NULL; #endif /* ENABLE_MIGRATION */ guint version; version = g_settings_get_uint (terminal_app_get_global_settings (app), TERMINAL_SETTING_SCHEMA_VERSION); if (version >= TERMINAL_SCHEMA_VERSION) { _terminal_debug_print (TERMINAL_DEBUG_SERVER | TERMINAL_DEBUG_PROFILE, "Schema version is %u, already migrated.\n", version); return; } #ifdef ENABLE_MIGRATION if (!g_spawn_sync (NULL /* our home directory */, (char **) argv, NULL /* envv */, 0, NULL, NULL, NULL, NULL, &status, &error)) { g_printerr ("Failed to migrate settings: %s\n", error->message); return; } if (WIFEXITED (status)) { if (WEXITSTATUS (status) != 0) g_printerr ("Profile migrator exited with status %d\n", WEXITSTATUS (status)); } else { g_printerr ("Profile migrator exited abnormally.\n"); } #else g_settings_set_uint (terminal_app_get_global_settings (app), TERMINAL_SETTING_SCHEMA_VERSION, TERMINAL_SCHEMA_VERSION); #endif /* ENABLE_MIGRATION */ }
/* Update the tab stops for a GtkSourceView */ gboolean update_tabs(GtkSourceView *view) { I7App *theapp = i7_app_get(); GSettings *prefs = i7_app_get_prefs(theapp); unsigned spaces = g_settings_get_uint(prefs, PREFS_TAB_WIDTH); if(spaces == 0) spaces = DEFAULT_TAB_WIDTH; gtk_source_view_set_tab_width(view, spaces); /* Set the hanging indent on wrapped lines to be a number of pixels equal * to twice the number of spaces in a tab; i.e. we estimate a space to be * four pixels. Not always true, but close enough.*/ gboolean indent_wrapped = g_settings_get_boolean(prefs, PREFS_INDENT_WRAPPED); if(!indent_wrapped) spaces = 0; g_object_set(view, "indent", -2 * spaces, NULL); return FALSE; /* one-shot idle function */ }
/* Callback for beginning the print operation, we give the printed pages our tab width from the preferences, and the margins from the page setup dialog. */ static void on_begin_print(GtkPrintOperation *print, GtkPrintContext *context, I7Document *document) { I7App *theapp = i7_app_get(); GSettings *prefs = i7_app_get_prefs(theapp); GtkSourcePrintCompositor *compositor = gtk_source_print_compositor_new(i7_document_get_buffer(document)); g_signal_connect(print, "draw-page", G_CALLBACK(on_draw_page), compositor); g_signal_connect(print, "end-print", G_CALLBACK(on_end_print), compositor); /* Design our printed page */ unsigned tabwidth = g_settings_get_uint(prefs, PREFS_TAB_WIDTH); if(tabwidth == 0) tabwidth = DEFAULT_TAB_WIDTH; gtk_source_print_compositor_set_tab_width(compositor, tabwidth); gtk_source_print_compositor_set_wrap_mode(compositor, GTK_WRAP_WORD_CHAR); PangoFontDescription *font = get_font_description(); gchar *fontstring = pango_font_description_to_string(font); pango_font_description_free(font); gtk_source_print_compositor_set_body_font_name(compositor, fontstring); g_free(fontstring); GtkPageSetup *setup = i7_app_get_page_setup(i7_app_get()); gtk_source_print_compositor_set_top_margin(compositor, gtk_page_setup_get_top_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_bottom_margin(compositor, gtk_page_setup_get_bottom_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_left_margin(compositor, gtk_page_setup_get_left_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_right_margin(compositor, gtk_page_setup_get_right_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); /* Display a notification in the status bar while paginating */ i7_document_display_status_message(document, _("Paginating..."), PRINT_OPERATIONS); while(!gtk_source_print_compositor_paginate(compositor, context)) { i7_document_display_progress_percentage(document, gtk_source_print_compositor_get_pagination_progress(compositor)); while(gtk_events_pending()) gtk_main_iteration(); } i7_document_display_progress_percentage(document, 0.0); i7_document_remove_status_message(document, PRINT_OPERATIONS); gtk_print_operation_set_n_pages(print, gtk_source_print_compositor_get_n_pages(compositor)); }
static void ephy_embed_shell_setup_process_model (EphyEmbedShell *shell) { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); EphyPrefsProcessModel process_model; guint max_processes; if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_APPLICATION) process_model = EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS; else process_model = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_PROCESS_MODEL); switch (process_model) { case EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS: max_processes = 1; break; case EPHY_PREFS_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW: max_processes = g_settings_get_uint (EPHY_SETTINGS_MAIN, EPHY_PREFS_MAX_PROCESSES); break; } webkit_web_context_set_process_model (priv->web_context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); webkit_web_context_set_web_process_count_limit (priv->web_context, max_processes); }
void UpdateLimSetting() { decoration::Style::Get()->integrated_menus = g_settings_get_boolean(usettings_, LIM_KEY.c_str()); parent_->lim_movement_thresold = g_settings_get_uint(lim_settings_, CLICK_MOVEMENT_THRESHOLD.c_str()); parent_->lim_double_click_wait = g_settings_get_uint(lim_settings_, DOUBLE_CLICK_WAIT.c_str()); }
static void dialog_update_state (CcNightLightDialog *self) { gboolean automatic; gboolean disabled_until_tomorrow = FALSE; gboolean enabled; gdouble value = 0.f; g_autoptr(GDateTime) dt = g_date_time_new_now_local (); GtkToggleButton *toggle_button; /* only show the infobar if we are disabled */ if (self->proxy_color != NULL) { g_autoptr(GVariant) disabled = NULL; disabled = g_dbus_proxy_get_cached_property (self->proxy_color, "DisabledUntilTomorrow"); if (disabled != NULL) disabled_until_tomorrow = g_variant_get_boolean (disabled); } gtk_widget_set_visible (self->infobar_disabled, disabled_until_tomorrow); /* make things insensitive if the switch is disabled */ enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled"); automatic = g_settings_get_boolean (self->settings_display, "night-light-schedule-automatic"); self->ignore_value_changed = TRUE; if (!enabled) toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_off); else if (automatic) toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_automatic); else toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_manual); gtk_toggle_button_set_active (toggle_button, TRUE); self->ignore_value_changed = FALSE; gtk_widget_set_sensitive (self->box_manual, enabled && !automatic); gtk_widget_set_sensitive (self->scale_color_temperature, enabled); /* Don't show the off button if it can't be turned off */ /* Don't allow choosing Manual or "Sunset to Sunrise" if it can't be turned on */ if (!g_settings_is_writable (self->settings_display, "night-light-enabled")) { gtk_widget_set_visible (self->togglebutton_off, !enabled); gtk_widget_set_sensitive (self->togglebutton_box, enabled); } else { gtk_widget_set_visible (self->togglebutton_off, TRUE); gtk_widget_set_sensitive (self->togglebutton_box, TRUE); } /* Don't show the Manual buttons if Manual can't be enabled. Same for "Sunset to Sunrise". */ if (!g_settings_is_writable (self->settings_display, "night-light-schedule-automatic")) { gtk_widget_set_visible (self->togglebutton_automatic, automatic); gtk_widget_set_visible (self->togglebutton_manual, !automatic); gtk_widget_set_visible (self->box_manual, !automatic); } else { gtk_widget_set_visible (self->togglebutton_automatic, TRUE); gtk_widget_set_visible (self->togglebutton_manual, TRUE); gtk_widget_set_visible (self->box_manual, TRUE); } /* set from */ if (automatic && self->proxy_color != NULL) { g_autoptr(GVariant) sunset = NULL; sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunset"); if (sunset != NULL) { value = g_variant_get_double (sunset); } else { value = 16.0f; g_warning ("no sunset data, using %02.2f", value); } } else { value = g_settings_get_double (self->settings_display, "night-light-schedule-from"); value = fmod (value, 24.f); } dialog_adjustments_set_frac_hours (self, value, self->adjustment_from_hours, self->adjustment_from_minutes, self->stack_from); /* set to */ if (automatic && self->proxy_color != NULL) { g_autoptr(GVariant) sunset = NULL; sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunrise"); if (sunset != NULL) { value = g_variant_get_double (sunset); } else { value = 8.0f; g_warning ("no sunrise data, using %02.2f", value); } } else { value = g_settings_get_double (self->settings_display, "night-light-schedule-to"); value = fmod (value, 24.f); } dialog_adjustments_set_frac_hours (self, value, self->adjustment_to_hours, self->adjustment_to_minutes, self->stack_to); self->ignore_value_changed = TRUE; value = (gdouble) g_settings_get_uint (self->settings_display, "night-light-temperature"); gtk_adjustment_set_value (self->adjustment_color_temperature, value); self->ignore_value_changed = FALSE; }
/* this is loosely based on update_places() from caja-places-sidebar.c */ static void panel_place_menu_item_append_remote_gio (PanelPlaceMenuItem *place_item, GtkWidget *menu) { GtkWidget *add_menu; GList *mounts, *l; GMount *mount; GSList *add_mounts, *sl; /* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */ mounts = g_volume_monitor_get_mounts (place_item->priv->volume_monitor); add_mounts = NULL; for (l = mounts; l; l = l->next) { GVolume *volume; GFile *root; mount = l->data; if (g_mount_is_shadowed (mount)) { g_object_unref (mount); continue; } volume = g_mount_get_volume (mount); if (volume != NULL) { g_object_unref (volume); g_object_unref (mount); continue; } root = g_mount_get_root (mount); if (g_file_is_native (root)) { g_object_unref (root); g_object_unref (mount); continue; } g_object_unref (root); add_mounts = g_slist_prepend (add_mounts, mount); } add_mounts = g_slist_reverse (add_mounts); if (g_slist_length (add_mounts) <= g_settings_get_uint (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)) { add_menu = menu; } else { GtkWidget *item; item = panel_image_menu_item_new (); setup_menuitem_with_icon (item, panel_menu_icon_get_size (), NULL, PANEL_ICON_NETWORK_SERVER, _("Network Places")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); add_menu = create_empty_menu (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), add_menu); } for (sl = add_mounts; sl; sl = sl->next) { mount = sl->data; panel_menu_item_append_mount (add_menu, mount); g_object_unref (mount); } g_slist_free (add_mounts); g_list_free (mounts); }
/* this is loosely based on update_places() from caja-places-sidebar.c */ static void panel_place_menu_item_append_local_gio (PanelPlaceMenuItem *place_item, GtkWidget *menu) { GList *l; GList *ll; GList *drives; GDrive *drive; GList *volumes; GVolume *volume; GList *mounts; GMount *mount; GSList *items; GSList *sl; PanelGioItem *item; GtkWidget *add_menu; items = NULL; /* first go through all connected drives */ drives = g_volume_monitor_get_connected_drives (place_item->priv->volume_monitor); for (l = drives; l != NULL; l = l->next) { drive = l->data; volumes = g_drive_get_volumes (drive); if (volumes != NULL) { for (ll = volumes; ll != NULL; ll = ll->next) { volume = ll->data; mount = g_volume_get_mount (volume); item = g_slice_new (PanelGioItem); if (mount != NULL) { item->type = PANEL_GIO_MOUNT; item->u.mount = mount; } else { /* Do show the unmounted volumes; this * is so the user can mount it (in case * automounting is off). * * Also, even if automounting is * enabled, this gives a visual cue * that the user should remember to * yank out the media if he just * unmounted it. */ item->type = PANEL_GIO_VOLUME; item->u.volume = g_object_ref (volume); } items = g_slist_prepend (items, item); g_object_unref (volume); } g_list_free (volumes); } else { if (g_drive_is_media_removable (drive) && !g_drive_is_media_check_automatic (drive)) { /* If the drive has no mountable volumes and we * cannot detect media change.. we display the * drive so the user can manually poll the * drive by clicking on it..." * * This is mainly for drives like floppies * where media detection doesn't work.. but * it's also for human beings who like to turn * off media detection in the OS to save * battery juice. */ item = g_slice_new (PanelGioItem); item->type = PANEL_GIO_DRIVE; item->u.drive = g_object_ref (drive); items = g_slist_prepend (items, item); } } g_object_unref (drive); } g_list_free (drives); /* add all volumes that is not associated with a drive */ volumes = g_volume_monitor_get_volumes (place_item->priv->volume_monitor); for (l = volumes; l != NULL; l = l->next) { volume = l->data; drive = g_volume_get_drive (volume); if (drive != NULL) { g_object_unref (volume); g_object_unref (drive); continue; } mount = g_volume_get_mount (volume); item = g_slice_new (PanelGioItem); if (mount != NULL) { item->type = PANEL_GIO_MOUNT; item->u.mount = mount; } else { /* see comment above in why we add an icon for an * unmounted mountable volume */ item->type = PANEL_GIO_VOLUME; item->u.volume = g_object_ref (volume); } items = g_slist_prepend (items, item); g_object_unref (volume); } g_list_free (volumes); /* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */ mounts = g_volume_monitor_get_mounts (place_item->priv->volume_monitor); for (l = mounts; l != NULL; l = l->next) { GFile *root; mount = l->data; if (g_mount_is_shadowed (mount)) { g_object_unref (mount); continue; } volume = g_mount_get_volume (mount); if (volume != NULL) { g_object_unref (volume); g_object_unref (mount); continue; } root = g_mount_get_root (mount); if (!g_file_is_native (root)) { g_object_unref (root); g_object_unref (mount); continue; } g_object_unref (root); item = g_slice_new (PanelGioItem); item->type = PANEL_GIO_MOUNT; item->u.mount = mount; items = g_slist_prepend (items, item); } g_list_free (mounts); /* now that we have everything, add the items inline or in a submenu */ items = g_slist_reverse (items); if (g_slist_length (items) <= g_settings_get_uint (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)) { add_menu = menu; } else { GtkWidget *item; item = gtk_image_menu_item_new (); setup_menuitem_with_icon (item, panel_menu_icon_get_size (), NULL, PANEL_ICON_REMOVABLE_MEDIA, _("Removable Media")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); add_menu = create_empty_menu (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), add_menu); } for (sl = items; sl; sl = sl->next) { item = sl->data; switch (item->type) { case PANEL_GIO_DRIVE: panel_menu_item_append_drive (add_menu, item->u.drive); g_object_unref (item->u.drive); break; case PANEL_GIO_VOLUME: panel_menu_item_append_volume (add_menu, item->u.volume); g_object_unref (item->u.volume); break; case PANEL_GIO_MOUNT: panel_menu_item_append_mount (add_menu, item->u.mount); g_object_unref (item->u.mount); break; default: g_assert_not_reached (); } g_slice_free (PanelGioItem, item); } g_slist_free (items); }
static GtkWidget * panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) { GtkWidget *places_menu; GtkWidget *item; char *gsettings_name = NULL; char *name; char *uri; GFile *file; places_menu = panel_create_menu (); file = g_file_new_for_path (g_get_home_dir ()); uri = g_file_get_uri (file); name = panel_util_get_label_for_uri (uri); g_object_unref (file); panel_menu_items_append_place_item (PANEL_ICON_HOME, NULL, name, _("Open your personal folder"), places_menu, G_CALLBACK (activate_home_uri), uri); g_free (name); g_free (uri); if (!place_item->priv->caja_prefs_settings || !g_settings_get_boolean (place_item->priv->caja_prefs_settings, CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY)) { file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)); uri = g_file_get_uri (file); g_object_unref (file); panel_menu_items_append_place_item ( PANEL_ICON_DESKTOP, NULL, /* Translators: Desktop is used here as in * "Desktop Folder" (this is not the Desktop * environment). */ C_("Desktop Folder", "Desktop"), _("Open the contents of your desktop in a folder"), places_menu, G_CALLBACK (activate_desktop_uri), /* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */ uri); g_free (uri); } panel_place_menu_item_append_gtk_bookmarks (places_menu, g_settings_get_uint (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)); add_menu_separator (places_menu); if (place_item->priv->caja_desktop_settings != NULL) gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings, CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY); if (PANEL_GLIB_STR_EMPTY (gsettings_name)) gsettings_name = g_strdup (_("Computer")); panel_menu_items_append_place_item ( PANEL_ICON_COMPUTER, NULL, gsettings_name, _("Browse all local and remote disks and folders accessible from this computer"), places_menu, G_CALLBACK (activate_uri), "computer://"); if (gsettings_name) g_free (gsettings_name); panel_place_menu_item_append_local_gio (place_item, places_menu); add_menu_separator (places_menu); panel_menu_items_append_place_item ( PANEL_ICON_NETWORK, NULL, _("Network"), _("Browse bookmarked and local network locations"), places_menu, G_CALLBACK (activate_uri), "network://"); panel_place_menu_item_append_remote_gio (place_item, places_menu); if (panel_is_program_in_path ("caja-connect-server") || panel_is_program_in_path ("nautilus-connect-server") || panel_is_program_in_path ("nemo-connect-server")) { item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER); if (item != NULL) gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item); } add_menu_separator (places_menu); if (panel_is_program_in_path ("mate-search-tool")) panel_menu_items_append_from_desktop (places_menu, "mate-search-tool.desktop", NULL, FALSE); else panel_menu_items_append_from_desktop (places_menu, "gnome-search-tool.desktop", NULL, FALSE); panel_recent_append_documents_menu (places_menu, place_item->priv->recent_manager); /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */ GtkWidget *toplevel = gtk_widget_get_toplevel (places_menu); GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); return places_menu; }
static void multiload_create_graphs(MultiloadApplet *ma) { struct { const char *label; const char *name; int num_colours; LoadGraphDataFunc callback; } graph_types[] = { { _("CPU Load"), "cpuload", 5, GetLoad }, { _("Memory Load"), "memload", 5, GetMemory }, { _("Net Load"), "netload2", 6, GetNet }, { _("Swap Load"), "swapload", 2, GetSwap }, { _("Load Average"), "loadavg", 3, GetLoadAvg }, { _("Disk Load"), "diskload", 3, GetDiskLoad } }; gint speed, size; guint net_threshold1; guint net_threshold2; guint net_threshold3; gint i; speed = g_settings_get_int (ma->settings, "speed"); size = g_settings_get_int (ma->settings, "size"); net_threshold1 = g_settings_get_uint (ma->settings, "netthreshold1"); net_threshold2 = g_settings_get_uint (ma->settings, "netthreshold2"); net_threshold3 = g_settings_get_uint (ma->settings, "netthreshold3"); if (net_threshold1 >= net_threshold2) { net_threshold1 = net_threshold2 - 1; } if (net_threshold2 >= net_threshold3) { net_threshold3 = net_threshold2 + 1; } speed = MAX (speed, 50); size = CLAMP (size, 10, 400); for (i = 0; i < G_N_ELEMENTS (graph_types); i++) { gboolean visible; char *key; /* This is a special case to handle migration from an * older version of netload to a newer one in the * 2.25.1 release. */ if (g_strcmp0 ("netload2", graph_types[i].name) == 0) { key = g_strdup ("view-netload"); } else { key = g_strdup_printf ("view-%s", graph_types[i].name); } visible = g_settings_get_boolean (ma->settings, key); g_free (key); ma->graphs[i] = load_graph_new (ma, graph_types[i].num_colours, graph_types[i].label, i, speed, size, visible, graph_types[i].name, graph_types[i].callback); } /* for Network graph, colors[4] is grid line color, it should not be used in loop in load-graph.c */ /* for Network graph, colors[5] is indicator color, it should not be used in loop in load-graph.c */ ma->graphs[2]->n = 4; ma->graphs[2]->net_threshold1 = net_threshold1; ma->graphs[2]->net_threshold2 = net_threshold2; ma->graphs[2]->net_threshold3 = net_threshold3; /* for Load graph, colors[2] is grid line color, it should not be used in loop in load-graph.c */ ma->graphs[4]->n = 2; }
static void cc_power_panel_init (CcPowerPanel *self) { GError *error; GtkWidget *widget; gint value; char *text; self->priv = POWER_PANEL_PRIVATE (self); self->priv->builder = gtk_builder_new (); gtk_builder_set_translation_domain (self->priv->builder, GETTEXT_PACKAGE); error = NULL; gtk_builder_add_from_file (self->priv->builder, SAGARMATHACC_UI_DIR "/power.ui", &error); if (error != NULL) { g_warning ("Could not load interface file: %s", error->message); g_error_free (error); return; } /* Make sure to set liststores (glade likes removing them from Gtk.ComboBoxText items in the .ui file....) */ gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_display_ac")), LS("liststore_display")); gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_display_battery")), LS("liststore_display")); gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_sleep_ac")), LS("liststore_suspend")); gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_sleep_battery")), LS("liststore_suspend")); gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_session_idle")), LS("liststore_session")); /* add levelbar */ self->priv->levelbar_primary = SWID("levelbar_primary"); self->priv->cancellable = g_cancellable_new (); /* get initial icon state */ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.sagarmatha.SettingsDaemon", "/org/sagarmatha/SettingsDaemon/Power", "org.sagarmatha.SettingsDaemon.Power", self->priv->cancellable, got_power_proxy_cb, self); /* find out if there are any battery or UPS devices attached * and setup UI accordingly */ self->priv->up_client = up_client_new (); set_ac_battery_ui_mode (self); self->priv->csd_settings = g_settings_new ("org.sagarmatha.settings-daemon.plugins.power"); self->priv->session_settings = g_settings_new ("org.sagarmatha.desktop.session"); /* Session idle time */ value = g_settings_get_uint (self->priv->session_settings, "idle-delay"); widget = SWID("combobox_session_idle"); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "idle-delay"); g_signal_connect (widget, "changed", G_CALLBACK (combo_session_time_changed_cb), self); /* auto-display-off time */ value = g_settings_get_int (self->priv->csd_settings, "sleep-display-ac"); widget = SWID("combobox_display_ac"); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-display-ac"); g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self); value = g_settings_get_int (self->priv->csd_settings, "sleep-display-battery"); widget = SWID("combobox_display_battery"); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-display-battery"); g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self); /* auto-sleep time */ value = g_settings_get_int (self->priv->csd_settings, "sleep-inactive-ac-timeout"); widget = SWID("combobox_sleep_ac"); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-ac-timeout"); g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self); value = g_settings_get_int (self->priv->csd_settings, "sleep-inactive-battery-timeout"); widget = SWID("combobox_sleep_battery"); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-battery-timeout"); g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self); /* actions */ value = g_settings_get_enum (self->priv->csd_settings, "critical-battery-action"); widget = SWID("combobox_critical"); disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget)); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "critical-battery-action"); g_signal_connect (widget, "changed", G_CALLBACK (combo_enum_changed_cb), self); value = g_settings_get_enum (self->priv->csd_settings, "lid-close-ac-action"); widget = SWID("combobox_lid_ac"); disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget)); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "lid-close-ac-action"); g_signal_connect (widget, "changed", G_CALLBACK (combo_enum_changed_cb), self); value = g_settings_get_enum (self->priv->csd_settings, "lid-close-battery-action"); widget = SWID("combobox_lid_battery"); disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget)); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT(widget), "_gsettings_key", "lid-close-battery-action"); g_signal_connect (widget, "changed", G_CALLBACK (combo_enum_changed_cb), self); widget = SWID ("vbox_power"); gtk_widget_reparent (widget, (GtkWidget *) self); value = g_settings_get_enum (self->priv->csd_settings, "button-power"); widget = SWID ("combobox_power_button"); disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget)); set_value_for_combo (GTK_COMBO_BOX (widget), value); g_object_set_data (G_OBJECT (widget), "_gsettings_key", "button-power"); g_signal_connect (widget, "changed", G_CALLBACK (combo_enum_changed_cb), self); }
void gs_screenshot_image_load_async (GsScreenshotImage *ssimg, GCancellable *cancellable) { AsImage *im = NULL; const gchar *url; g_autofree gchar *basename = NULL; g_autofree gchar *cache_kind = NULL; g_autofree gchar *cachefn_thumb = NULL; g_autofree gchar *sizedir = NULL; g_autoptr(SoupURI) base_uri = NULL; g_return_if_fail (GS_IS_SCREENSHOT_IMAGE (ssimg)); g_return_if_fail (AS_IS_SCREENSHOT (ssimg->screenshot)); g_return_if_fail (ssimg->width != 0); g_return_if_fail (ssimg->height != 0); /* load an image according to the scale factor */ ssimg->scale = (guint) gtk_widget_get_scale_factor (GTK_WIDGET (ssimg)); im = as_screenshot_get_image (ssimg->screenshot, ssimg->width * ssimg->scale, ssimg->height * ssimg->scale); /* if we've failed to load a HiDPI image, fallback to LoDPI */ if (im == NULL && ssimg->scale > 1) { ssimg->scale = 1; im = as_screenshot_get_image (ssimg->screenshot, ssimg->width, ssimg->height); } if (im == NULL) { /* TRANSLATORS: this is when we request a screenshot size that * the generator did not create or the parser did not add */ gs_screenshot_image_set_error (ssimg, _("Screenshot size not found")); return; } /* check if the URL points to a local file */ url = as_image_get_url (im); if (g_str_has_prefix (url, "file://")) { g_free (ssimg->filename); ssimg->filename = g_strdup (url + 7); if (g_file_test (ssimg->filename, G_FILE_TEST_EXISTS)) { as_screenshot_show_image (ssimg); return; } } basename = gs_screenshot_get_cachefn_for_url (url); if (ssimg->width == G_MAXUINT || ssimg->height == G_MAXUINT) { sizedir = g_strdup ("unknown"); } else { sizedir = g_strdup_printf ("%ux%u", ssimg->width * ssimg->scale, ssimg->height * ssimg->scale); } cache_kind = g_build_filename ("screenshots", sizedir, NULL); g_free (ssimg->filename); ssimg->filename = gs_utils_get_cache_filename (cache_kind, basename, GS_UTILS_CACHE_FLAG_NONE, NULL); if (ssimg->filename == NULL) { /* TRANSLATORS: this is when we try create the cache directory * but we were out of space or permission was denied */ gs_screenshot_image_set_error (ssimg, _("Could not create cache")); return; } /* does local file already exist and has recently been downloaded */ if (g_file_test (ssimg->filename, G_FILE_TEST_EXISTS)) { guint64 age_max; g_autoptr(GFile) file = NULL; /* show the image we have in cache while we're checking for the * new screenshot (which probably won't have changed) */ as_screenshot_show_image (ssimg); /* verify the cache age against the maximum allowed */ age_max = g_settings_get_uint (ssimg->settings, "screenshot-cache-age-maximum"); file = g_file_new_for_path (ssimg->filename); /* image new enough, not re-requesting from server */ if (age_max > 0 && gs_utils_get_file_age (file) < age_max) return; } /* if we're not showing a full-size image, we try loading a blurred * smaller version of it straight away */ if (!ssimg->showing_image && ssimg->width > AS_IMAGE_THUMBNAIL_WIDTH && ssimg->height > AS_IMAGE_THUMBNAIL_HEIGHT) { const gchar *url_thumb; g_autofree gchar *basename_thumb = NULL; g_autofree gchar *cache_kind_thumb = NULL; im = as_screenshot_get_image (ssimg->screenshot, AS_IMAGE_THUMBNAIL_WIDTH * ssimg->scale, AS_IMAGE_THUMBNAIL_HEIGHT * ssimg->scale); url_thumb = as_image_get_url (im); basename_thumb = gs_screenshot_get_cachefn_for_url (url_thumb); cache_kind_thumb = g_build_filename ("screenshots", "112x63", NULL); cachefn_thumb = gs_utils_get_cache_filename (cache_kind_thumb, basename_thumb, GS_UTILS_CACHE_FLAG_NONE, NULL); if (cachefn_thumb == NULL) return; if (g_file_test (cachefn_thumb, G_FILE_TEST_EXISTS)) gs_screenshot_image_show_blurred (ssimg, cachefn_thumb); } /* re-request the cache filename, which might be different as it needs * to be writable this time */ g_free (ssimg->filename); ssimg->filename = gs_utils_get_cache_filename (cache_kind, basename, GS_UTILS_CACHE_FLAG_WRITEABLE, NULL); /* download file */ g_debug ("downloading %s to %s", url, ssimg->filename); base_uri = soup_uri_new (url); if (base_uri == NULL || !SOUP_URI_VALID_FOR_HTTP (base_uri)) { /* TRANSLATORS: this is when we try to download a screenshot * that was not a valid URL */ gs_screenshot_image_set_error (ssimg, _("Screenshot not valid")); return; } /* cancel any previous messages */ if (ssimg->message != NULL) { soup_session_cancel_message (ssimg->session, ssimg->message, SOUP_STATUS_CANCELLED); g_clear_object (&ssimg->message); } ssimg->message = soup_message_new_from_uri (SOUP_METHOD_GET, base_uri); if (ssimg->message == NULL) { /* TRANSLATORS: this is when networking is not available */ gs_screenshot_image_set_error (ssimg, _("Screenshot not available")); return; } /* not all servers support If-Modified-Since, but worst case we just * re-download the entire file again every 30 days */ if (g_file_test (ssimg->filename, G_FILE_TEST_EXISTS)) { g_autoptr(GFile) file = g_file_new_for_path (ssimg->filename); gs_screenshot_soup_msg_set_modified_request (ssimg->message, file); } /* send async */ soup_session_queue_message (ssimg->session, g_object_ref (ssimg->message) /* transfer full */, gs_screenshot_image_complete_cb, g_object_ref (ssimg)); }