gboolean workspace_switcher_applet_fill(MatePanelApplet* applet) { PagerData* pager; GtkActionGroup* action_group; gchar* ui_path; gboolean display_names; pager = g_new0(PagerData, 1); pager->applet = GTK_WIDGET(applet); mate_panel_applet_set_flags(MATE_PANEL_APPLET(pager->applet), MATE_PANEL_APPLET_EXPAND_MINOR); setup_gsettings(pager); pager->n_rows = g_settings_get_int(pager->settings, "num-rows"); pager->n_rows = CLAMP(pager->n_rows, 1, MAX_REASONABLE_ROWS); display_names = g_settings_get_boolean(pager->settings, "display-workspace-names"); pager->wrap_workspaces = g_settings_get_boolean(pager->settings, "wrap-workspaces"); if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } pager->display_all = g_settings_get_boolean(pager->settings, "display-all-workspaces"); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 0, 0) pager->pager = wnck_pager_new(); #else pager->pager = wnck_pager_new(NULL); #endif #else pager->pager = wnck_pager_new(NULL); #endif pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; 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); gtk_container_add(GTK_CONTAINER(pager->applet), pager->pager); gtk_widget_show(pager->pager); g_signal_connect(G_OBJECT(pager->applet), "realize", G_CALLBACK(applet_realized), pager); g_signal_connect(G_OBJECT(pager->applet), "unrealize", G_CALLBACK(applet_unrealized), 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); gtk_widget_show(pager->applet); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(pager->applet), GTK_WIDGET(pager->applet)); action_group = gtk_action_group_new("WorkspaceSwitcher Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, pager_menu_actions, G_N_ELEMENTS(pager_menu_actions), pager); ui_path = g_build_filename(WNCK_MENU_UI_DIR, "workspace-switcher-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(pager->applet), ui_path, action_group); g_free(ui_path); if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(pager->applet))) { GtkAction *action; action = gtk_action_group_get_action(action_group, "PagerPreferences"); gtk_action_set_visible(action, FALSE); } g_object_unref(action_group); return TRUE; }
/* Config struct routines */ void mail_config_init (EMailSession *session) { g_return_if_fail (E_IS_MAIL_SESSION (session)); if (config) return; config = g_new0 (MailConfig, 1); mail_settings = g_settings_new ("org.gnome.evolution.mail"); /* Composer Configuration */ settings_outlook_filenames_changed ( mail_settings, "composer-outlook-filenames", NULL); g_signal_connect ( mail_settings, "changed::composer-outlook-filenames", G_CALLBACK (settings_outlook_filenames_changed), NULL); /* Display Configuration */ g_signal_connect ( mail_settings, "changed::address-compress", G_CALLBACK (settings_bool_value_changed), &config->address_compress); config->address_compress = g_settings_get_boolean ( mail_settings, "address-compress"); g_signal_connect ( mail_settings, "changed::address-count", G_CALLBACK (settings_int_value_changed), &config->address_count); config->address_count = g_settings_get_int ( mail_settings, "address-count"); /* Junk Configuration */ g_signal_connect ( mail_settings, "changed::junk-check-custom-header", G_CALLBACK (settings_jh_check_changed), session); config->jh_check = g_settings_get_boolean ( mail_settings, "junk-check-custom-header"); g_signal_connect ( mail_settings, "changed::junk-custom-header", G_CALLBACK (settings_jh_headers_changed), session); g_signal_connect ( mail_settings, "changed::junk-lookup-addressbook", G_CALLBACK (settings_bool_value_changed), &config->book_lookup); config->book_lookup = g_settings_get_boolean ( mail_settings, "junk-lookup-addressbook"); g_signal_connect ( mail_settings, "changed::junk-lookup-addressbook-local-only", G_CALLBACK (settings_bool_value_changed), &config->book_lookup_local_only); config->book_lookup_local_only = g_settings_get_boolean ( mail_settings, "junk-lookup-addressbook-local-only"); settings_jh_check_changed (mail_settings, NULL, session); }
int main (int argc, char *argv[]) { MateSettingsManager *manager; DBusGConnection *bus; gboolean res; GError *error; GSettings *debug_settings = NULL; manager = NULL; mate_settings_profile_start (NULL); bindtextdomain (GETTEXT_PACKAGE, MATE_SETTINGS_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); parse_args (&argc, &argv); /* Allows to enable/disable debug from GSettings only if it is not set from argument */ if (mate_gsettings_schema_exists (DEBUG_SCHEMA)) { debug_settings = g_settings_new (DEBUG_SCHEMA); debug = g_settings_get_boolean (debug_settings, DEBUG_KEY); g_signal_connect (debug_settings, "changed::" DEBUG_KEY, G_CALLBACK (debug_changed), NULL); if (debug) { g_setenv ("G_MESSAGES_DEBUG", "all", FALSE); } } mate_settings_profile_start ("opening gtk display"); if (! gtk_init_check (NULL, NULL)) { g_warning ("Unable to initialize GTK+"); exit (EXIT_FAILURE); } mate_settings_profile_end ("opening gtk display"); g_log_set_default_handler (msd_log_default_handler, NULL); bus = get_session_bus (); if (bus == NULL) { g_warning ("Could not get a connection to the bus"); goto out; } if (! bus_register (bus)) { goto out; } #ifdef HAVE_LIBNOTIFY notify_init ("mate-settings-daemon"); #endif /* HAVE_LIBNOTIFY */ mate_settings_profile_start ("mate_settings_manager_new"); manager = mate_settings_manager_new (); mate_settings_profile_end ("mate_settings_manager_new"); if (manager == NULL) { g_warning ("Unable to register object"); goto out; } set_session_over_handler (bus, manager); /* If we aren't started by dbus then load the plugins automatically. Otherwise, wait for an Awake etc. */ if (g_getenv ("DBUS_STARTER_BUS_TYPE") == NULL) { error = NULL; res = mate_settings_manager_start (manager, &error); if (! res) { g_warning ("Unable to start: %s", error->message); g_error_free (error); goto out; } } if (do_timed_exit) { g_timeout_add_seconds (30, (GSourceFunc) timed_exit_cb, NULL); } gtk_main (); out: if (bus != NULL) { dbus_g_connection_unref (bus); } if (manager != NULL) { g_object_unref (manager); } if (debug_settings != NULL) { g_object_unref (debug_settings); } #ifdef HAVE_LIBNOTIFY if (notify_is_initted ()) notify_uninit (); #endif /* HAVE_LIBNOTIFY */ g_debug ("SettingsDaemon finished"); mate_settings_profile_end (NULL); return 0; }
void active_sensor_update(ActiveSensor *active_sensor, SensorsApplet *sensors_applet) { GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; /* instance data from the tree for this sensor */ gchar *sensor_path = NULL; gchar *sensor_id = NULL; gchar *sensor_label = NULL; SensorType sensor_type; gchar *sensor_interface; gboolean sensor_enabled; gdouble sensor_low_value; gdouble sensor_high_value; gboolean sensor_alarm_enabled; gdouble sensor_multiplier; gdouble sensor_offset; gdouble sensor_value; GdkPixbuf *icon_pixbuf; gchar *graph_color; /* to build the list of labels as we go */ gchar *value_text = NULL; gchar *old_value_text; TemperatureScale scale; DisplayMode display_mode; GError *error = NULL; gchar *tooltip = NULL; gchar *value_tooltip = NULL; /* hidden gsettings options */ gint font_size = 0; gboolean hide_units = FALSE; g_assert(active_sensor); g_assert(active_sensor->sensor_row); g_assert(sensors_applet); model = gtk_tree_row_reference_get_model(active_sensor->sensor_row); path = gtk_tree_row_reference_get_path(active_sensor->sensor_row); /* if can successfully get iter can proceed */ if (gtk_tree_model_get_iter(model, &iter, path)) { gtk_tree_path_free(path); gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &iter, PATH_COLUMN, &sensor_path, ID_COLUMN, &sensor_id, LABEL_COLUMN, &sensor_label, INTERFACE_COLUMN, &sensor_interface, SENSOR_TYPE_COLUMN, &sensor_type, ENABLE_COLUMN, &sensor_enabled, LOW_VALUE_COLUMN, &sensor_low_value, HIGH_VALUE_COLUMN, &sensor_high_value, ALARM_ENABLE_COLUMN, &sensor_alarm_enabled, MULTIPLIER_COLUMN, &sensor_multiplier, OFFSET_COLUMN, &sensor_offset, ICON_PIXBUF_COLUMN, &icon_pixbuf, GRAPH_COLOR_COLUMN, &graph_color, -1); SensorsAppletPluginGetSensorValue get_sensor_value; /* only call function if is in hash table for plugin */ if ((get_sensor_value = sensors_applet_plugins_get_sensor_value_func(sensors_applet, sensor_interface)) != NULL) { sensor_value = get_sensor_value(sensor_path, sensor_id, sensor_type, &error); if (error) { g_debug("Error updating active sensor: %s", error->message); sensors_applet_notify_active_sensor(active_sensor, SENSOR_INTERFACE_ERROR); /* hard code text as ERROR */ value_text = g_strdup(_("ERROR")); value_tooltip = g_strdup_printf("- %s", error->message); g_error_free(error); error = NULL; /* set sensor value to an error code - * note this is not unique */ sensor_value = -1; } else { /* use hidden gsettings key for hide_units */ hide_units = g_settings_get_boolean(sensors_applet->settings, HIDE_UNITS); /* scale value and set text using this * value */ switch (sensor_type) { case TEMP_SENSOR: scale = (TemperatureScale) g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE); /* scale value */ sensor_value = sensors_applet_convert_temperature(sensor_value, CELSIUS, scale); sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; switch (scale) { case FAHRENHEIT: value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_FAHRENHEIT)); /* tooltip should * always display * units */ value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_FAHRENHEIT); break; case CELSIUS: value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_CELSIUS)); value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_CELSIUS); break; case KELVIN: value_text = g_strdup_printf("%2.0f", sensor_value); value_tooltip = g_strdup(value_text); break; } break; case FAN_SENSOR: sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; value_text = g_strdup_printf("%4.0f %s", sensor_value, (hide_units ? "" : UNITS_RPM)); value_tooltip = g_strdup_printf("%4.0f %s", sensor_value, UNITS_RPM); break; case VOLTAGE_SENSOR: sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_VOLTAGE)); value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_VOLTAGE); break; case CURRENT_SENSOR: sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_CURRENT)); value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_CURRENT); break; } /* end switch(sensor_type) */ } /* end else on error */ /* setup for tooltips */ tooltip = g_strdup_printf("%s %s", sensor_label, value_tooltip); g_free(value_tooltip); /* only do icons and labels / graphs if needed */ display_mode = g_settings_get_int (sensors_applet->settings, DISPLAY_MODE); /* most users wont have a font size set */ font_size = g_settings_get_int (sensors_applet->settings, FONT_SIZE); /* do icon if needed */ if (display_mode == DISPLAY_ICON || display_mode == DISPLAY_ICON_WITH_VALUE) { /* update icon if icon range has changed if no * update has been done before */ if ((sensor_value_range(sensor_value, sensor_low_value, sensor_high_value) != sensor_value_range(active_sensor->sensor_values[0], active_sensor->sensor_low_value, active_sensor->sensor_high_value)) || !(active_sensor->updated)) { active_sensor_update_sensor_value(active_sensor, sensor_value); active_sensor->sensor_low_value = sensor_low_value; active_sensor->sensor_high_value = sensor_high_value; active_sensor_update_icon(active_sensor, icon_pixbuf, sensor_type); } /* always update tooltip */ gtk_widget_set_tooltip_text(active_sensor->icon, tooltip); } active_sensor_update_sensor_value(active_sensor, sensor_value); active_sensor->sensor_low_value = sensor_low_value; active_sensor->sensor_high_value = sensor_high_value; /* do graph if needed */ if (display_mode == DISPLAY_GRAPH) { /* update graph color in case has changed */ gdk_color_parse(graph_color, &(active_sensor->graph_color)); gtk_widget_queue_draw (active_sensor->graph); gtk_widget_set_tooltip_text(active_sensor->graph, tooltip); } old_value_text = value_text; if (sensor_alarm_enabled) { if (sensor_value >= sensor_high_value || sensor_value <= sensor_low_value) { /* make value text red and * activate alarm */ if (display_mode == DISPLAY_LABEL_WITH_VALUE || display_mode == DISPLAY_ICON_WITH_VALUE || display_mode == DISPLAY_VALUE) { value_text = g_markup_printf_escaped("<span foreground=\"#FF0000\">%s</span>", old_value_text); g_free(old_value_text); } /* could have both coditions at once */ if (sensor_value >= sensor_high_value) { active_sensor_alarm_on(active_sensor, HIGH_ALARM); } if (sensor_value <= sensor_low_value) { active_sensor_alarm_on(active_sensor, LOW_ALARM); } } else { /* make sure alarms are off */ active_sensor_all_alarms_off(active_sensor); } } else { /* else for if alarm enabled */ /* make sure all alarms are off */ active_sensor_all_alarms_off(active_sensor); } /* do value label */ if (display_mode == DISPLAY_LABEL_WITH_VALUE || display_mode == DISPLAY_ICON_WITH_VALUE || display_mode == DISPLAY_VALUE) { if (font_size) { old_value_text = value_text; value_text = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text); g_free(old_value_text); } gtk_label_set_markup(GTK_LABEL(active_sensor->value), value_text); gtk_widget_set_tooltip_text(active_sensor->value, tooltip); } /* finished with value text */ g_free(value_text); /* do label label */ if (display_mode == DISPLAY_LABEL_WITH_VALUE) { if (font_size) { old_value_text = sensor_label; sensor_label = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text); g_free(old_value_text); } gtk_label_set_markup(GTK_LABEL(active_sensor->label), sensor_label); gtk_widget_set_tooltip_text(active_sensor->label, tooltip); } g_free(tooltip); } else { g_debug("no get_sensor_value function yet installed for interface %s.", sensor_interface); } g_free(sensor_path); g_free(sensor_id); g_free(sensor_label); g_free(sensor_interface); g_free(graph_color); g_object_unref(icon_pixbuf); } else { g_debug("Error getting iter when updating sensor..."); } active_sensor->updated = TRUE; }
int main(int argc, char *argv[]) { UniqueApp *app; GtkStatusIcon *statusicon; GtkWidget *menu; GOptionContext *context; GError *error = NULL; bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); g_type_init (); /* Parse command-line options */ context = g_option_context_new (N_("- Bluetooth applet")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); return 1; } if (option_debug == FALSE) { app = unique_app_new ("org.mate.Bluetooth.applet", NULL); if (unique_app_is_running (app)) { gdk_notify_startup_complete (); g_warning ("Applet is already running, exiting"); return 0; } } else { app = NULL; } g_set_application_name(_("Bluetooth Applet")); gtk_window_set_default_icon_name("bluetooth"); killswitch = bluetooth_killswitch_new (); g_signal_connect (G_OBJECT (killswitch), "state-changed", G_CALLBACK (killswitch_state_changed), NULL); menu = create_popupmenu(); client = bluetooth_client_new(); devices_model = bluetooth_client_get_model(client); g_signal_connect(G_OBJECT(devices_model), "row-inserted", G_CALLBACK(device_added), NULL); g_signal_connect(G_OBJECT(devices_model), "row-deleted", G_CALLBACK(device_removed), NULL); g_signal_connect (G_OBJECT (devices_model), "row-changed", G_CALLBACK (device_changed), NULL); /* Set the default adapter */ device_changed (devices_model, NULL, NULL, NULL); if (bluetooth_killswitch_has_killswitches (killswitch) != FALSE) { killswitch_state_changed (killswitch, bluetooth_killswitch_get_state (killswitch)); } /* Make sure all the unblocked adapters are powered, * so as to avoid seeing unpowered, but unblocked * devices */ bluetooth_set_adapter_powered (); settings = g_settings_new (SCHEMA_NAME); show_icon_pref = g_settings_get_boolean (settings, PREF_SHOW_ICON); g_signal_connect (G_OBJECT (settings), "changed::" PREF_SHOW_ICON, G_CALLBACK (show_icon_changed), NULL); statusicon = init_notification(); update_icon_visibility(); g_signal_connect(statusicon, "activate", G_CALLBACK(activate_callback), menu); g_signal_connect(statusicon, "popup-menu", G_CALLBACK(popup_callback), menu); setup_agents(); gtk_main(); gtk_widget_destroy(menu); g_object_unref(settings); cleanup_agents(); cleanup_notification(); g_object_unref(devices_model); g_object_unref(client); if (app != NULL) g_object_unref (app); return 0; }
void dlg_resize_images (GthBrowser *browser, GList *file_list) { DialogData *data; GArray *savers; GthFileData *first_file_data; GthUnit unit; int default_width_in_pixels; int default_height_in_pixels; if (gth_browser_get_dialog (browser, "resize_images") != NULL) { gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "resize_images"))); return; } data = g_new0 (DialogData, 1); data->browser = browser; data->builder = _gtk_builder_new_from_file ("resize-images.ui", "resize_images"); data->settings = g_settings_new (GTHUMB_RESIZE_IMAGES_SCHEMA); data->file_list = gth_file_data_list_dup (file_list); data->use_destination = TRUE; /* Get the widgets. */ data->dialog = _gtk_builder_get_widget (data->builder, "resize_images_dialog"); gth_browser_set_dialog (browser, "resize_images", data->dialog); g_object_set_data (G_OBJECT (data->dialog), "dialog_data", data); /* Set widgets data. */ first_file_data = (GthFileData *) data->file_list->data; _gtk_file_chooser_set_file_parent (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")), first_file_data->file, NULL); unit = g_settings_get_enum (data->settings, PREF_RESIZE_IMAGES_UNIT); gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("unit_combobox")), unit); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_ratio_checkbutton")), g_settings_get_boolean (data->settings, PREF_RESIZE_IMAGES_KEEP_RATIO)); default_width_in_pixels = DEFAULT_WIDTH_PIXELS; default_height_in_pixels = DEFAULT_HEIGHT_PIXELS; if (data->file_list->next == NULL) { GthMetadataProvider *provider; int width; int height; provider = g_object_new (GTH_TYPE_METADATA_PROVIDER_IMAGE, NULL); gth_metadata_provider_read (provider, first_file_data, "image::width,image::height", NULL); width = g_file_info_get_attribute_int32 (first_file_data->info, "image::width"); height = g_file_info_get_attribute_int32 (first_file_data->info, "image::height"); if ((width > 0) && (height > 0)) { data->known_ratio = TRUE; data->ratio = (double) width / height; default_width_in_pixels = width; default_height_in_pixels = height; } g_object_unref (provider); } if (unit == GTH_UNIT_PERCENTAGE) { data->latest_width_in_pixel = default_width_in_pixels; data->latest_height_in_pixel = default_height_in_pixels; data->latest_width_in_percentage = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_WIDTH); data->latest_height_in_percentage = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_HEIGHT); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_percentage); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_percentage); } else if (unit == GTH_UNIT_PIXELS) { data->latest_width_in_percentage = DEFAULT_WIDTH_PERCENTAGE; data->latest_height_in_percentage = DEFAULT_HEIGHT_PERCENTAGE; data->latest_width_in_pixel = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_WIDTH); data->latest_height_in_pixel = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_HEIGHT); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_pixel); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_pixel); } savers = gth_main_get_type_set ("image-saver"); if (savers != NULL) { GtkListStore *list_store; GtkTreeIter iter; char *default_mime_type; GthIconCache *icon_cache; int i; list_store = (GtkListStore *) GET_WIDGET ("mime_type_liststore"); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, MIME_TYPE_COLUMN_ICON, NULL, MIME_TYPE_COLUMN_TYPE, NULL, MIME_TYPE_COLUMN_DESCRIPTION, _("Keep the original format"), -1); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (GET_WIDGET ("mime_type_combobox")), &iter); default_mime_type = g_settings_get_string (data->settings, PREF_RESIZE_IMAGES_MIME_TYPE); icon_cache = gth_icon_cache_new_for_widget (data->dialog, GTK_ICON_SIZE_MENU); for (i = 0; i < savers->len; i++) { GType saver_type; GthImageSaver *saver; const char *mime_type; GdkPixbuf *pixbuf; saver_type = g_array_index (savers, GType, i); saver = g_object_new (saver_type, NULL); mime_type = gth_image_saver_get_mime_type (saver); pixbuf = gth_icon_cache_get_pixbuf (icon_cache, g_content_type_get_icon (mime_type)); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, MIME_TYPE_COLUMN_ICON, pixbuf, MIME_TYPE_COLUMN_TYPE, mime_type, MIME_TYPE_COLUMN_DESCRIPTION, g_content_type_get_description (mime_type), -1); if (strcmp (default_mime_type, mime_type) == 0) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (GET_WIDGET ("mime_type_combobox")), &iter); g_object_unref (pixbuf); g_object_unref (saver); } gth_icon_cache_free (icon_cache); g_free (default_mime_type); } /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (GET_WIDGET ("ok_button"), "clicked", G_CALLBACK (ok_clicked_cb), data); g_signal_connect (GET_WIDGET ("help_button"), "clicked", G_CALLBACK (help_clicked_cb), data); g_signal_connect_swapped (GET_WIDGET ("cancel_button"), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (data->dialog)); g_signal_connect (GET_WIDGET ("unit_combobox"), "changed", G_CALLBACK (unit_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("use_destination_checkbutton"), "toggled", G_CALLBACK (use_destination_checkbutton_toggled_cb), data); data->width_spinbutton_event = g_signal_connect (GET_WIDGET ("width_spinbutton"), "value-changed", G_CALLBACK (width_spinbutton_value_changed_cb), data); data->height_spinbutton_event = g_signal_connect (GET_WIDGET ("height_spinbutton"), "value-changed", G_CALLBACK (height_spinbutton_value_changed_cb), data); /* Run dialog. */ update_width_height_properties (data); width_spinbutton_value_changed_cb (NULL, data); if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser))) gtk_widget_hide (GET_WIDGET ("use_destination_checkbutton")); gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser)); gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE); gtk_widget_show (data->dialog); }
int main (int argc, char *argv[]) { char **player_names; gsize n_player_names; guint i; GOptionContext *context; gboolean retval; GError *error = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); application = gtk_application_new ("org.gnome.Tali", 0); g_signal_connect (application, "startup", G_CALLBACK (GyahtzeeCreateMainWindow), NULL); g_signal_connect (application, "activate", G_CALLBACK (GyahtzeeActivateGame), NULL); games_scores_startup (); /* Reset all yahtzee variables before parsing args */ YahtzeeInit (); context = g_option_context_new (NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, yahtzee_options, GETTEXT_PACKAGE); retval = g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (!retval) { g_print ("%s", error->message); g_error_free (error); exit (1); } settings = g_settings_new ("org.gnome.Tali"); g_set_application_name (_(appName)); /* If we're in computer test mode, just run some tests, no GUI */ if (test_computer_play > 0) { gint ii, jj, kk; gdouble sum_scores = 0.0; game_type = GAME_YAHTZEE; if (game_type_string) game_type = game_type_from_string (game_type_string); g_message ("In test computer play section - Using %d trials for simulation", NUM_TRIALS); for (ii = 0; ii < test_computer_play; ii++) { int num_rolls = 0; NumberOfHumans = 0; NumberOfComputers = 1; NewGame (); while (!GameIsOver () && num_rolls < 100) { ComputerRolling (CurrentPlayer); if (NoDiceSelected () || (NumberOfRolls >= NUM_ROLLS)) { ComputerScoring (CurrentPlayer); NumberOfRolls = 0; SelectAllDice (); RollSelectedDice (); } else { RollSelectedDice (); } num_rolls++; } for (kk = NumberOfHumans; kk < NumberOfPlayers; kk++) { printf ("Computer score: %d\n", total_score (kk)); sum_scores += total_score (kk); if (num_rolls > 98) { for (jj = 0; jj < NUM_FIELDS; jj++) g_message ("Category %d is score %d", jj, players[kk].score[jj]); } } } printf ("Computer average: %.2f for %d trials\n", sum_scores / test_computer_play, NUM_TRIALS); exit (0); } highscores = games_scores_new ("tali", category_array, G_N_ELEMENTS (category_array), "game type", NULL, 0 /* default category */, GAMES_SCORES_STYLE_PLAIN_DESCENDING); gtk_window_set_default_icon_name ("org.gnome.Tali"); if (NumberOfComputers == 0) /* Not set on the command-line. */ NumberOfComputers = g_settings_get_int (settings, "number-of-computer-opponents"); if (NumberOfHumans == 0) /* Not set on the command-line. */ NumberOfHumans = g_settings_get_int (settings, "number-of-human-opponents"); if (NumberOfHumans < 1) NumberOfHumans = 1; if (NumberOfComputers < 0) NumberOfComputers = 0; if (NumberOfHumans > MAX_NUMBER_OF_PLAYERS) NumberOfHumans = MAX_NUMBER_OF_PLAYERS; if ((NumberOfHumans + NumberOfComputers) > MAX_NUMBER_OF_PLAYERS) NumberOfComputers = MAX_NUMBER_OF_PLAYERS - NumberOfHumans; if (game_type_string) game_type = game_type_from_string (game_type_string); else { char *type; type = g_settings_get_string (settings, "game-type"); game_type = game_type_from_string (type); } set_new_game_type (game_type); if (NUM_TRIALS <= 0) NUM_TRIALS = g_settings_get_int (settings, "monte-carlo-trials"); if (DoDelay == 0) /* Not set on the command-line */ DoDelay = g_settings_get_boolean (settings, "delay-between-rolls"); if (DisplayComputerThoughts == 0) /* Not set on the command-line */ DisplayComputerThoughts = g_settings_get_boolean (settings, "display-computer-thoughts"); /* Read in new player names */ player_names = g_settings_get_strv (settings, "player-names"); n_player_names = g_strv_length (player_names); if (player_names) { n_player_names = MIN (n_player_names, MAX_NUMBER_OF_PLAYERS); for (i = 0; i < n_player_names; ++i) { if (i == 0 && strcasecmp (player_names[i], _("Human")) == 0) { const char *realname; realname = g_get_real_name (); if (realname && realname[0] && strcmp (realname, "Unknown") != 0) { players[i].name = g_locale_to_utf8 (realname, -1, NULL, NULL, NULL); } if (!players[i].name) { players[i].name = g_strdup (player_names[i]); } } else { players[i].name = g_strdup (player_names[i]); } } g_strfreev (player_names); } g_application_run (G_APPLICATION (application), argc, argv); exit (0); }
static void dlg_extract__common (FrWindow *window, GList *selected_files, char *base_dir_for_selection) { DialogData *data; GtkWidget *file_sel; data = g_new0 (DialogData, 1); data->settings = g_settings_new (ENGRAMPA_SCHEMA_EXTRACT); data->window = window; data->selected_files = selected_files; data->base_dir_for_selection = base_dir_for_selection; data->extract_clicked = FALSE; data->dialog = file_sel = gtk_file_chooser_dialog_new (_("Extract"), GTK_WINDOW (data->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, FR_STOCK_EXTRACT, GTK_RESPONSE_OK, GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL); gtk_window_set_default_size (GTK_WINDOW (file_sel), 530, 510); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_sel), FALSE); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE); gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK); gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_sel), create_extra_widget (data)); /* Set widgets data. */ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), fr_window_get_extract_default_dir (window)); if (data->selected_files != NULL) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_selected_radiobutton), TRUE); else { gtk_widget_set_sensitive (data->e_selected_radiobutton, FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_all_radiobutton), TRUE); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_overwrite_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_OVERWRITE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_SKIP_NEWER)); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_overwrite_checkbutton))) { gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton), TRUE); gtk_widget_set_sensitive (data->e_not_newer_checkbutton, FALSE); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_recreate_dir_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_RECREATE_FOLDERS)); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (G_OBJECT (file_sel), "response", G_CALLBACK (file_sel_response_cb), data); g_signal_connect (G_OBJECT (data->e_overwrite_checkbutton), "toggled", G_CALLBACK (overwrite_toggled_cb), data); g_signal_connect (G_OBJECT (data->e_files_entry), "changed", G_CALLBACK (files_entry_changed_cb), data); /* Run dialog. */ gtk_window_set_modal (GTK_WINDOW (file_sel),TRUE); gtk_widget_show (file_sel); }
void dlg_batch_add_files (FrWindow *window, GList *file_list) { DialogData *data; GtkWidget *cancel_button; GtkWidget *help_button; GtkWidget *add_button; GtkWidget *a_archive_type_box; GtkSizeGroup *size_group; char *automatic_name = NULL; char *default_ext; const char *first_filename; char *parent; int i; if (file_list == NULL) return; data = g_new0 (DialogData, 1); data->settings = g_settings_new (ENGRAMPA_SCHEMA_BATCH_ADD); data->settings_general = g_settings_new (ENGRAMPA_SCHEMA_GENERAL); data->builder = _gtk_builder_new_from_file ("batch-add-files.ui"); if (data->builder == NULL) { g_free (data); return; } data->window = window; data->file_list = file_list; data->single_file = ((file_list->next == NULL) && uri_is_file ((char*) file_list->data)); data->add_clicked = FALSE; /* Get the widgets. */ data->dialog = _gtk_builder_get_widget (data->builder, "batch_add_files_dialog"); data->a_add_to_entry = _gtk_builder_get_widget (data->builder, "a_add_to_entry"); data->a_location_filechooserbutton = _gtk_builder_get_widget (data->builder, "a_location_filechooserbutton"); data->a_password_entry = _gtk_builder_get_widget (data->builder, "a_password_entry"); data->a_password_label = _gtk_builder_get_widget (data->builder, "a_password_label"); data->a_other_options_expander = _gtk_builder_get_widget (data->builder, "a_other_options_expander"); data->a_encrypt_header_checkbutton = _gtk_builder_get_widget (data->builder, "a_encrypt_header_checkbutton"); data->a_volume_checkbutton = _gtk_builder_get_widget (data->builder, "a_volume_checkbutton"); data->a_volume_spinbutton = _gtk_builder_get_widget (data->builder, "a_volume_spinbutton"); data->a_volume_box = _gtk_builder_get_widget (data->builder, "a_volume_box"); add_button = _gtk_builder_get_widget (data->builder, "a_add_button"); cancel_button = _gtk_builder_get_widget (data->builder, "a_cancel_button"); help_button = _gtk_builder_get_widget (data->builder, "a_help_button"); a_archive_type_box = _gtk_builder_get_widget (data->builder, "a_archive_type_box"); data->add_image = _gtk_builder_get_widget (data->builder, "a_add_image"); /* Set widgets data. */ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); gtk_size_group_add_widget (size_group, _gtk_builder_get_widget (data->builder, "a_archive_label")); gtk_size_group_add_widget (size_group, _gtk_builder_get_widget (data->builder, "a_location_label")); gtk_size_group_add_widget (size_group, _gtk_builder_get_widget (data->builder, "a_password_label")); gtk_button_set_use_stock (GTK_BUTTON (add_button), TRUE); gtk_button_set_label (GTK_BUTTON (add_button), FR_STOCK_CREATE_ARCHIVE); gtk_expander_set_expanded (GTK_EXPANDER (data->a_other_options_expander), FALSE /*g_settings_get_boolean (data->settings, PREF_BATCH_ADD_OTHER_OPTIONS)*/); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton), g_settings_get_boolean (data->settings_general, PREF_GENERAL_ENCRYPT_HEADER)); gtk_spin_button_set_value (GTK_SPIN_BUTTON (data->a_volume_spinbutton), (double) g_settings_get_int (data->settings, PREF_BATCH_ADD_VOLUME_SIZE) / MEGABYTE); first_filename = (char*) file_list->data; parent = remove_level_from_path (first_filename); if (file_list->next == NULL) automatic_name = g_uri_unescape_string (file_name_from_path ((char*) file_list->data), NULL); else { automatic_name = g_uri_unescape_string (file_name_from_path (parent), NULL); if ((automatic_name == NULL) || (automatic_name[0] == '\0')) { g_free (automatic_name); automatic_name = g_uri_unescape_string (file_name_from_path (first_filename), NULL); } } _gtk_entry_set_filename_text (GTK_ENTRY (data->a_add_to_entry), automatic_name); g_free (automatic_name); if (check_permissions (parent, R_OK | W_OK)) gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (data->a_location_filechooserbutton), parent); else gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (data->a_location_filechooserbutton), get_home_uri ()); g_free (parent); /* archive type combobox */ data->a_archive_type_combo_box = gtk_combo_box_new_text (); if (data->single_file) data->supported_types = single_file_save_type; else data->supported_types = save_type; sort_mime_types_by_extension (data->supported_types); for (i = 0; data->supported_types[i] != -1; i++) gtk_combo_box_append_text (GTK_COMBO_BOX (data->a_archive_type_combo_box), mime_type_desc[data->supported_types[i]].default_ext); gtk_box_pack_start (GTK_BOX (a_archive_type_box), data->a_archive_type_combo_box, TRUE, TRUE, 0); gtk_widget_show_all (a_archive_type_box); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (data->dialog)); g_signal_connect (G_OBJECT (add_button), "clicked", G_CALLBACK (add_clicked_cb), data); g_signal_connect (G_OBJECT (help_button), "clicked", G_CALLBACK (help_clicked_cb), data); g_signal_connect (G_OBJECT (data->a_archive_type_combo_box), "changed", G_CALLBACK (archive_type_combo_box_changed_cb), data); g_signal_connect (G_OBJECT (data->a_password_entry), "changed", G_CALLBACK (password_entry_changed_cb), data); g_signal_connect (G_OBJECT (data->a_volume_checkbutton), "toggled", G_CALLBACK (volume_toggled_cb), data); /* Run dialog. */ default_ext = g_settings_get_string (data->settings, PREF_BATCH_ADD_DEFAULT_EXTENSION); update_archive_type_combo_box_from_ext (data, default_ext); g_free (default_ext); gtk_widget_grab_focus (data->a_add_to_entry); gtk_editable_select_region (GTK_EDITABLE (data->a_add_to_entry), 0, -1); update_sensitivity (data); gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE); gtk_window_present (GTK_WINDOW (data->dialog)); }
/** * gpm_control_hibernate: **/ gboolean gpm_control_hibernate (GpmControl *control, GError **error) { gboolean allowed = FALSE; gboolean ret = FALSE; gboolean do_lock; gboolean nm_sleep; EggConsoleKit *console; GpmScreensaver *screensaver; guint32 throttle_cookie = 0; #ifdef WITH_KEYRING gboolean lock_gnome_keyring; GnomeKeyringResult keyres; #endif /* WITH_KEYRING */ GError *dbus_error = NULL; GDBusProxy *proxy; GVariant *res = NULL; screensaver = gpm_screensaver_new (); if (!LOGIND_RUNNING()) { console = egg_console_kit_new (); egg_console_kit_can_hibernate (console, &allowed, NULL); g_object_unref (console); if (!allowed) { egg_debug ("cannot hibernate as not allowed from policy"); g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot hibernate"); goto out; } } #ifdef WITH_KEYRING /* we should perhaps lock keyrings when sleeping #375681 */ lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_HIBERNATE); if (lock_gnome_keyring) { keyres = gnome_keyring_lock_all_sync (); if (keyres != GNOME_KEYRING_RESULT_OK) { egg_warning ("could not lock keyring"); } } #endif /* WITH_KEYRING */ do_lock = gpm_control_get_lock_policy (control, GPM_SETTINGS_LOCK_ON_HIBERNATE); if (do_lock) { throttle_cookie = gpm_screensaver_add_throttle (screensaver, "hibernate"); gpm_screensaver_lock (screensaver); } nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_sleep (); egg_debug ("emitting sleep"); g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_HIBERNATE); if (LOGIND_RUNNING()) { /* sleep via logind */ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", NULL, &dbus_error ); if (proxy == NULL) { egg_error("Error connecting to dbus - %s", dbus_error->message); g_error_free (dbus_error); ret = FALSE; goto out; } res = g_dbus_proxy_call_sync (proxy, "Hibernate", g_variant_new( "(b)",FALSE), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_error ); if (dbus_error != NULL ) { egg_debug ("Error in dbus - %s", dbus_error->message); g_error_free (dbus_error); ret = TRUE; } else { g_variant_unref(res); ret = TRUE; } } else { console = egg_console_kit_new (); ret = egg_console_kit_hibernate (console, error); g_object_unref (console); } egg_debug ("emitting resume"); g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE); if (do_lock) { gpm_screensaver_poke (screensaver); if (throttle_cookie) gpm_screensaver_remove_throttle (screensaver, throttle_cookie); } nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_wake (); out: g_object_unref (screensaver); return ret; }
void modeline_parser_apply_modeline (GtkSourceView *view) { ModelineOptions options; GtkTextBuffer *buffer; GtkTextIter iter, liter; gint line_count; GSettings *settings; options.language_id = NULL; options.set = MODELINE_SET_NONE; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); gtk_text_buffer_get_start_iter (buffer, &iter); line_count = gtk_text_buffer_get_line_count (buffer); /* Parse the modelines on the 10 first lines... */ while ((gtk_text_iter_get_line (&iter) < 10) && !gtk_text_iter_is_end (&iter)) { gchar *line; liter = iter; gtk_text_iter_forward_to_line_end (&iter); line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE); parse_modeline (line, 1 + gtk_text_iter_get_line (&iter), line_count, &options); gtk_text_iter_forward_line (&iter); g_free (line); } /* ...and on the 10 last ones (modelines are not allowed in between) */ if (!gtk_text_iter_is_end (&iter)) { gint cur_line; guint remaining_lines; /* we are on the 11th line (count from 0) */ cur_line = gtk_text_iter_get_line (&iter); /* g_assert (10 == cur_line); */ remaining_lines = line_count - cur_line - 1; if (remaining_lines > 10) { gtk_text_buffer_get_end_iter (buffer, &iter); gtk_text_iter_backward_lines (&iter, 9); } } while (!gtk_text_iter_is_end (&iter)) { gchar *line; liter = iter; gtk_text_iter_forward_to_line_end (&iter); line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE); parse_modeline (line, 1 + gtk_text_iter_get_line (&iter), line_count, &options); gtk_text_iter_forward_line (&iter); g_free (line); } /* Try to set language */ if (has_option (&options, MODELINE_SET_LANGUAGE) && options.language_id) { if (g_ascii_strcasecmp (options.language_id, "text") == 0) { gedit_document_set_language (GEDIT_DOCUMENT (buffer), NULL); } else { GtkSourceLanguageManager *manager; GtkSourceLanguage *language; manager = gtk_source_language_manager_get_default (); language = gtk_source_language_manager_get_language (manager, options.language_id); if (language != NULL) { gedit_document_set_language (GEDIT_DOCUMENT (buffer), language); } else { gedit_debug_message (DEBUG_PLUGINS, "Unknown language `%s'", options.language_id); } } } ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer), MODELINE_OPTIONS_DATA_KEY); settings = g_settings_new ("org.gnome.gedit.preferences.editor"); /* Apply the options we got from modelines and restore defaults if we set them before */ if (has_option (&options, MODELINE_SET_INSERT_SPACES)) { gtk_source_view_set_insert_spaces_instead_of_tabs (view, options.insert_spaces); } else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES)) { gboolean insert_spaces; insert_spaces = g_settings_get_boolean (settings, GEDIT_SETTINGS_INSERT_SPACES); gtk_source_view_set_insert_spaces_instead_of_tabs (view, insert_spaces); } if (has_option (&options, MODELINE_SET_TAB_WIDTH)) { gtk_source_view_set_tab_width (view, options.tab_width); } else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH)) { guint tab_width; g_settings_get (settings, GEDIT_SETTINGS_TABS_SIZE, "u", &tab_width); gtk_source_view_set_tab_width (view, tab_width); } if (has_option (&options, MODELINE_SET_INDENT_WIDTH)) { gtk_source_view_set_indent_width (view, options.indent_width); } else if (check_previous (view, previous, MODELINE_SET_INDENT_WIDTH)) { gtk_source_view_set_indent_width (view, -1); } if (has_option (&options, MODELINE_SET_WRAP_MODE)) { gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode); } else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE)) { GtkWrapMode mode; mode = g_settings_get_enum (settings, GEDIT_SETTINGS_WRAP_MODE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), mode); } if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION)) { gtk_source_view_set_right_margin_position (view, options.right_margin_position); } else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION)) { guint right_margin_pos; g_settings_get (settings, GEDIT_SETTINGS_RIGHT_MARGIN_POSITION, "u", &right_margin_pos); gtk_source_view_set_right_margin_position (view, right_margin_pos); } if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN)) { gtk_source_view_set_show_right_margin (view, options.display_right_margin); } else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN)) { gboolean display_right_margin; display_right_margin = g_settings_get_boolean (settings, GEDIT_SETTINGS_DISPLAY_RIGHT_MARGIN); gtk_source_view_set_show_right_margin (view, display_right_margin); } if (previous) { g_free (previous->language_id); *previous = options; previous->language_id = g_strdup (options.language_id); } else { previous = g_slice_new (ModelineOptions); *previous = options; previous->language_id = g_strdup (options.language_id); g_object_set_data_full (G_OBJECT (buffer), MODELINE_OPTIONS_DATA_KEY, previous, (GDestroyNotify)free_modeline_options); } g_object_unref (settings); g_free (options.language_id); }
static gboolean mud_subwindow_entry_keypress_cb(GtkWidget *widget, GdkEventKey *event, MudSubwindow *self) { const gchar *history; if ((event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) && (event->state & gtk_accelerator_get_default_mod_mask()) == 0 && gtk_widget_get_mapped(self->priv->entry) ) { gchar *head = g_queue_peek_head(self->priv->history); const gchar *text = gtk_entry_get_text(GTK_ENTRY(self->priv->entry)); if( (head && !g_str_equal(head, text)) || g_queue_is_empty(self->priv->history)) { gchar *history_item = g_strdup(text); g_strstrip(history_item); /* Don't queue empty lines */ if(strlen(history_item) != 0) g_queue_push_head(self->priv->history, history_item); else g_free(history_item); } self->priv->current_history_index = -1; g_signal_emit(self, mud_subwindow_signal[INPUT], 0, text); if (g_settings_get_boolean(self->priv->parent_view->profile->settings, "keep-text")) gtk_editable_select_region(GTK_EDITABLE(self->priv->entry), 0, -1); else gtk_entry_set_text(GTK_ENTRY(self->priv->entry), ""); return TRUE; } if(event->keyval == GDK_KEY_Up) { history = mud_subwindow_get_history_item(self, SUBWINDOW_HISTORY_UP); if(history) { gtk_entry_set_text(GTK_ENTRY(self->priv->entry), history); gtk_editable_select_region(GTK_EDITABLE(self->priv->entry), 0, -1); } return TRUE; } if(event->keyval == GDK_KEY_Down) { history = mud_subwindow_get_history_item(self, SUBWINDOW_HISTORY_DOWN); if(history) { gtk_entry_set_text(GTK_ENTRY(self->priv->entry), history); gtk_editable_select_region(GTK_EDITABLE(self->priv->entry), 0, -1); } return TRUE; } return FALSE; }
gboolean window_list_applet_fill(MatePanelApplet* applet) { TasklistData* tasklist; GtkActionGroup* action_group; gchar* ui_path; #if GTK_CHECK_VERSION (3, 20, 0) GtkCssProvider *provider; GdkScreen *screen; #endif tasklist = g_new0(TasklistData, 1); tasklist->applet = GTK_WIDGET(applet); #if GTK_CHECK_VERSION (3, 20, 0) provider = gtk_css_provider_new (); screen = gdk_screen_get_default (); gtk_css_provider_load_from_data (provider, ".mate-panel-menu-bar button,\n" " #tasklist-button {\n" " padding: 0px;\n" " margin: 0px;\n }", -1, NULL); gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); #endif mate_panel_applet_set_flags(MATE_PANEL_APPLET(tasklist->applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE); setup_gsettings(tasklist); tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces"); tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows"); tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows"); tasklist->size = mate_panel_applet_get_size(applet); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } tasklist->tasklist = wnck_tasklist_new(); #if WNCK_CHECK_VERSION (3, 4, 6) wnck_tasklist_set_orientation (WNCK_TASKLIST (tasklist->tasklist), tasklist->orientation); wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist), TRUE); #endif wnck_tasklist_set_icon_loader(WNCK_TASKLIST(tasklist->tasklist), icon_loader_func, tasklist, NULL); g_signal_connect(G_OBJECT(tasklist->tasklist), "destroy", G_CALLBACK(destroy_tasklist), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "size_allocate", G_CALLBACK(applet_size_allocate), 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); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(tasklist->applet), GTK_WIDGET(tasklist->applet)); action_group = gtk_action_group_new("Tasklist Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions), tasklist); /* disable the item of system monitor, if not exists. * example, mate-system-monitor, o gnome-system-monitor */ char* programpath; int i; for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1) { programpath = g_find_program_in_path(system_monitors[i]); if (programpath != NULL) { g_free(programpath); /* we give up */ goto _system_monitor_found; } /* search another */ } /* system monitor not found */ gtk_action_set_visible(gtk_action_group_get_action(action_group, "TasklistSystemMonitor"), FALSE); _system_monitor_found:; /* end of system monitor item */ ui_path = g_build_filename(WNCK_MENU_UI_DIR, "window-list-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(tasklist->applet), ui_path, action_group); g_free(ui_path); if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(tasklist->applet))) { GtkAction* action; action = gtk_action_group_get_action(action_group, "TasklistPreferences"); gtk_action_set_visible(action, FALSE); } g_object_unref(action_group); gtk_widget_show(tasklist->applet); return TRUE; }
void mate_panel_applet_save_position (AppletInfo *applet_info, const char *id, gboolean immediate) { PanelWidget *panel_widget; const char *toplevel_id; char *old_toplevel_id; gboolean right_stick; gboolean locked; int position; g_return_if_fail (applet_info != NULL); if (!immediate) { if (!queued_position_source) queued_position_source = g_timeout_add_seconds (1, (GSourceFunc) mate_panel_applet_position_save_timeout, NULL); if (!g_slist_find (queued_position_saves, applet_info)) queued_position_saves = g_slist_prepend (queued_position_saves, applet_info); return; } if (!(toplevel_id = mate_panel_applet_get_toplevel_id (applet_info))) return; panel_widget = mate_panel_applet_get_panel_widget (applet_info); /* FIXME: Instead of getting keys, comparing and setting, there should be a dirty flag */ old_toplevel_id = g_settings_get_string (applet_info->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY); if (old_toplevel_id == NULL || strcmp (old_toplevel_id, toplevel_id) != 0) g_settings_set_string (applet_info->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY, toplevel_id); g_free (old_toplevel_id); /* Note: changing some properties of the panel that may not be locked down (e.g. background) can change the state of the "panel_right_stick" and "position" properties of an applet that may in fact be locked down. So check if these are writable before attempting to write them */ right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0; if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) && (g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) ? 1 : 0) != right_stick) g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, right_stick); position = mate_panel_applet_get_position (applet_info); if (right_stick && !panel_widget->packed) position = panel_widget->size - position; if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_POSITION_KEY) && g_settings_get_int (applet_info->settings, PANEL_OBJECT_POSITION_KEY) != position) g_settings_set_int (applet_info->settings, PANEL_OBJECT_POSITION_KEY, position); locked = panel_widget_get_applet_locked (panel_widget, applet_info->widget) ? 1 : 0; if (g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_LOCKED_KEY) ? 1 : 0 != locked) g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_LOCKED_KEY, locked); }
static gboolean location_button_should_be_active (CajaNavigationWindowPane *pane) { return g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); }
static void import_dialog_response_cb (GtkDialog *dialog, int response_id, gpointer user_data) { DialogData *data = user_data; switch (response_id) { case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: gth_file_list_cancel (GTH_FILE_LIST (data->file_list), (DataFunc) gtk_widget_destroy, data->dialog); break; case GTK_RESPONSE_OK: { GtkTreeIter iter; FlickrPhotoset *photoset; GList *file_list; if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("photoset_combobox")), &iter)) { gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE); return; } gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("photoset_liststore")), &iter, PHOTOSET_DATA_COLUMN, &photoset, -1); file_list = get_files_to_download (data); if (file_list != NULL) { GSettings *settings; GFile *destination; gboolean single_subfolder; GthSubfolderType subfolder_type; GthSubfolderFormat subfolder_format; char *custom_format; GthTask *task; settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA); destination = gth_import_preferences_get_destination (); subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE); subfolder_format = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_FORMAT); single_subfolder = g_settings_get_boolean (settings, PREF_IMPORTER_SUBFOLDER_SINGLE); custom_format = g_settings_get_string (settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT); task = gth_import_task_new (data->browser, file_list, destination, subfolder_type, subfolder_format, single_subfolder, custom_format, (photoset->title != NULL ? photoset->title : ""), NULL, FALSE, FALSE, FALSE); gth_browser_exec_task (data->browser, task, GTH_TASK_FLAGS_DEFAULT); gtk_widget_destroy (data->dialog); g_object_unref (task); _g_object_unref (destination); g_object_unref (settings); } _g_object_list_unref (file_list); g_object_unref (photoset); } break; default: break; } }
gboolean caja_navigation_window_pane_hide_temporary_bars (CajaNavigationWindowPane *pane) { CajaWindowSlot *slot; CajaDirectory *directory; gboolean success; g_assert (CAJA_IS_NAVIGATION_WINDOW_PANE (pane)); slot = CAJA_WINDOW_PANE(pane)->active_slot; success = FALSE; if (pane->temporary_location_bar) { if (caja_navigation_window_pane_location_bar_showing (pane)) { caja_navigation_window_pane_hide_location_bar (pane, FALSE); } pane->temporary_location_bar = FALSE; success = TRUE; } if (pane->temporary_navigation_bar) { directory = caja_directory_get (slot->location); if (CAJA_IS_SEARCH_DIRECTORY (directory)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_SEARCH); } else { if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH); } } pane->temporary_navigation_bar = FALSE; success = TRUE; caja_directory_unref (directory); } if (pane->temporary_search_bar) { CajaNavigationWindow *window; if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH); } else { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_NAVIGATION); } window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window); caja_navigation_window_set_search_button (window, FALSE); pane->temporary_search_bar = FALSE; success = TRUE; } return success; }
int main(int argc, char** argv) { struct sigaction sa; GError* error; #if GTK_CHECK_VERSION (3, 0, 0) const char* display_str; #else char* display_str; #endif GsmManager* manager; GsmStore* client_store; GsmXsmpServer* xsmp_server; GSettings* accessibility_settings; MdmSignalHandler* signal_handler; static char** override_autostart_dirs = NULL; static GOptionEntry entries[] = { {"autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), NULL}, {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL}, {"failsafe", 'f', 0, G_OPTION_ARG_NONE, &failsafe, N_("Do not load user-specified applications"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL}, {NULL, 0, 0, 0, NULL, NULL, NULL } }; /* Make sure that we have a session bus */ if (!require_dbus_session(argc, argv, &error)) { gsm_util_init_error(TRUE, "%s", error->message); } bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); sa.sa_handler = SIG_IGN; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGPIPE, &sa, 0); error = NULL; gtk_init_with_args(&argc, &argv, (char*) _(" - the MATE session manager"), entries, GETTEXT_PACKAGE, &error); if (error != NULL) { g_warning("%s", error->message); exit(1); } if (show_version) { g_print("%s %s\n", argv [0], VERSION); exit(1); } mdm_log_init(); mdm_log_set_debug(debug); /* Set DISPLAY explicitly for all our children, in case --display * was specified on the command line. */ #if GTK_CHECK_VERSION (3, 0, 0) display_str = gdk_display_get_name (gdk_display_get_default()); #else display_str = gdk_get_display(); #endif gsm_util_setenv("DISPLAY", display_str); #if !GTK_CHECK_VERSION (3, 0, 0) g_free(display_str); #endif /* Some third-party programs rely on MATE_DESKTOP_SESSION_ID to * detect if MATE is running. We keep this for compatibility reasons. */ gsm_util_setenv("MATE_DESKTOP_SESSION_ID", "this-is-deprecated"); /* * Make sure gsettings is set up correctly. If not, then bail. */ if (initialize_gsettings () != TRUE) exit (1); /* Look if accessibility is enabled */ accessibility_settings = g_settings_new (ACCESSIBILITY_SCHEMA); if (g_settings_get_boolean (accessibility_settings, ACCESSIBILITY_KEY)) { gsm_util_setenv("GTK_MODULES", "gail:atk-bridge"); } g_object_unref (accessibility_settings); client_store = gsm_store_new(); xsmp_server = gsm_xsmp_server_new(client_store); /* Now make sure they succeeded. (They'll call * gsm_util_init_error() if they failed.) */ acquire_name(); /* Starts gnome compat mode */ msm_gnome_start(); manager = gsm_manager_new(client_store, failsafe); signal_handler = mdm_signal_handler_new(); mdm_signal_handler_add_fatal(signal_handler); mdm_signal_handler_add(signal_handler, SIGFPE, signal_cb, NULL); mdm_signal_handler_add(signal_handler, SIGHUP, signal_cb, NULL); mdm_signal_handler_add(signal_handler, SIGUSR1, signal_cb, NULL); mdm_signal_handler_add(signal_handler, SIGTERM, signal_cb, manager); mdm_signal_handler_add(signal_handler, SIGINT, signal_cb, manager); mdm_signal_handler_set_fatal_func(signal_handler, shutdown_cb, manager); if (override_autostart_dirs != NULL) { load_override_apps(manager, override_autostart_dirs); } else { load_standard_apps(manager, GSM_DEFAULT_SESSION_KEY); } gsm_xsmp_server_start(xsmp_server); gsm_manager_start(manager); gtk_main(); if (xsmp_server != NULL) { g_object_unref(xsmp_server); } if (manager != NULL) { g_debug("Unreffing manager"); g_object_unref(manager); } if (client_store != NULL) { g_object_unref(client_store); } msm_gnome_stop(); mdm_log_shutdown(); return 0; }
/** * main * @argc: number of arguments * @argv: arguments * * Description: * main * * Returns: * exit code **/ int main (int argc, char *argv[]) { GtkWidget *errordialog; GtkWidget *vbox, *menubar, *toolbar, *statusbar, *gridframe; GtkUIManager *ui_manager; GOptionContext *context; struct timeval tv; gint i; gchar *config; gboolean retval; GError *error = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); games_scores_startup (); gettimeofday (&tv, NULL); srand (tv.tv_usec); context = g_option_context_new (NULL); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); retval = g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (!retval) { g_print ("%s", error->message); g_error_free (error); exit (1); } g_set_application_name (_("Robots")); highscores = games_scores_new ("gnome-robots", scorecats, G_N_ELEMENTS (scorecats), NULL, NULL, 0 /* default category */, GAMES_SCORES_STYLE_PLAIN_DESCENDING); settings = g_settings_new ("org.gnome.robots"); gtk_window_set_default_icon_name ("gnome-robots"); app = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (app), _("Robots")); g_signal_connect (GTK_WINDOW (app), "configure-event", G_CALLBACK (window_configure_event_cb), NULL); g_signal_connect (GTK_WINDOW (app), "window-state-event", G_CALLBACK (window_state_event_cb), NULL); gtk_window_set_default_size (GTK_WINDOW (app), g_settings_get_int (settings, "window-width"), g_settings_get_int (settings, "window-height")); if (g_settings_get_boolean (settings, "window-is-fullscreen")) gtk_window_fullscreen (GTK_WINDOW (app)); if (g_settings_get_boolean (settings, "window-is-maximized")) gtk_window_maximize (GTK_WINDOW (app)); g_signal_connect (G_OBJECT (app), "delete_event", G_CALLBACK (quit_game), NULL); statusbar = gnobots_statusbar_new (); ui_manager = gtk_ui_manager_new (); games_stock_prepare_for_statusbar_tooltips (ui_manager, statusbar); create_game_menus (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (app), gtk_ui_manager_get_accel_group (ui_manager)); menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); toolbar = gtk_ui_manager_get_widget (ui_manager, "/Toolbar"); gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR); make_cursors (); game_area = gtk_drawing_area_new (); gtk_widget_add_events (game_area, GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect (G_OBJECT (game_area), "button-press-event", G_CALLBACK (mouse_cb), NULL); g_signal_connect (G_OBJECT (game_area), "motion-notify-event", G_CALLBACK (move_cb), NULL); g_signal_connect (G_OBJECT (game_area), "configure-event", G_CALLBACK (resize_cb), NULL); g_signal_connect (G_OBJECT (game_area), "draw", G_CALLBACK (draw_cb), NULL); gridframe = games_grid_frame_new (GAME_WIDTH, GAME_HEIGHT); gtk_container_add (GTK_CONTAINER (gridframe), game_area); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), gridframe, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (app), vbox); gtk_widget_set_size_request (GTK_WIDGET (game_area), MINIMUM_TILE_WIDTH * GAME_WIDTH, MINIMUM_TILE_HEIGHT * GAME_HEIGHT); /* Set the window position if it was set by the session manager */ if (session_xpos >= 0 && session_ypos >= 0) { gtk_window_move (GTK_WINDOW (app), session_xpos, session_ypos); } gtk_widget_show_all (app); if (!load_game_configs ()) { /* Oops, no configs, we probably haven't been installed properly. */ errordialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "<b>%s</b>\n\n%s", _("No game data could be found."), _ ("The program Robots was unable to find any valid game configuration files. Please check that the program is installed correctly.")); gtk_window_set_resizable (GTK_WINDOW (errordialog), FALSE); gtk_dialog_run (GTK_DIALOG (errordialog)); exit (1); } load_properties (); if (!load_game_graphics ()) { /* Oops, no graphics, we probably haven't been installed properly. */ errordialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (app), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "<b>%s</b>\n\n%s", _ ("Some graphics files are missing or corrupt."), _ ("The program Robots was unable to load all the necessary graphics files. Please check that the program is installed correctly.")); gtk_dialog_run (GTK_DIALOG (errordialog)); exit (1); } connect_toolbar_toggle (toolbar); init_sound (); init_game (); if (cmdline_scenario) { set_game_graphics (cmdline_scenario); } if (cmdline_config) { for (i = 0; i < num_game_configs (); ++i) { config = game_config_name (i); if (!strcmp (cmdline_config, config)) { properties_set_config (i); g_free (config); break; } g_free (config); } } gtk_main (); g_settings_sync(); return 0; }
void cpp_java_indentation_char_added (IAnjutaEditor *editor, IAnjutaIterable *insert_pos, gchar ch, IndentCPlugin *plugin) { IAnjutaEditorAttribute attrib; IAnjutaIterable *iter; gboolean should_auto_indent = FALSE; iter = ianjuta_iterable_clone (insert_pos, NULL); /* If autoindent is enabled*/ if (plugin->smart_indentation) { /* DEBUG_PRINT ("Char added at position %d: '%c'", insert_pos, ch); */ if (iter_is_newline (iter, ch)) { skip_iter_to_newline_head (iter, ch); /* All newline entries means enable indenting */ should_auto_indent = TRUE; } else if (ch == '{' || ch == '}' || ch == '#') { /* Indent only when it's the first non-white space char in the line */ /* Don't bother if we are inside string */ attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter), NULL); if (attrib != IANJUTA_EDITOR_STRING) { /* Iterate backwards till the begining of the line and disable * indenting if any non-white space char is encountered */ /* Begin by assuming it should be indented */ should_auto_indent = TRUE; while (ianjuta_iterable_previous (iter, NULL)) { ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL); //DEBUG_PRINT ("Looking at char '%c'", ch); /* Break on begining of line (== end of previous line) */ if (iter_is_newline (iter, ch)) { skip_iter_to_newline_head (iter, ch); break; } /* If a non-white space char is encountered, disabled indenting */ if (!isspace (ch)) { should_auto_indent = FALSE; break; } } } } if (should_auto_indent) { gint insert_line; gint line_indent; gint parenthesis_indentation; ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL); insert_line = ianjuta_editor_get_lineno (editor, NULL); line_indent = get_line_auto_indentation (plugin, editor, insert_line, &parenthesis_indentation); set_line_indentation (plugin, editor, insert_line, line_indent, parenthesis_indentation); ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL); } } if (g_settings_get_boolean (plugin->settings, PREF_BRACE_AUTOCOMPLETION)) { if (ch == '[' || ch == '(') { gchar *prev_char, *next_char; IAnjutaIterable *previous, *next, *next_end; previous = ianjuta_iterable_clone (iter, NULL); ianjuta_iterable_previous (previous, NULL); prev_char = ianjuta_editor_get_text (editor, previous, iter, NULL); next = ianjuta_iterable_clone (iter, NULL); ianjuta_iterable_next (next, NULL); next_end = ianjuta_iterable_clone (next, NULL); ianjuta_iterable_next (next_end, NULL); next_char = ianjuta_editor_get_text (editor, next, next_end, NULL); /* If the previous char is a ' we don't have to autocomplete, also we only autocomplete if the next character is white-space a closing bracket, "," or ";" */ if (*prev_char != '\'' && (g_ascii_isspace(*next_char) || is_closing_bracket (*next_char) || *next_char == ',' || *next_char == ';'|| *next_char == '\0')) { ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (editor), NULL); ianjuta_iterable_next (iter, NULL); switch (ch) { case '[': insert_editor_blocked (editor, iter, "]", plugin); break; case '(': insert_editor_blocked (editor, iter, ")", plugin); break; default: break; } ianjuta_editor_goto_position (editor, iter, NULL); ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (editor), NULL); } g_object_unref (previous); } else if (ch == '"' || ch == '\'') { gchar *prev_char; IAnjutaIterable *previous; previous = ianjuta_iterable_clone (iter, NULL); ianjuta_iterable_previous (previous, NULL); prev_char = ianjuta_editor_get_text (editor, previous, iter, NULL); /* First iter*/ ianjuta_iterable_next (iter, NULL); /* * If the character is " we have to decide if we need insert * another " or we have to skip the character */ if (ch == '"' || ch == '\'') { /* * Now we have to detect if we want to manage " as a char */ if (*prev_char != '\'' && *prev_char != '\\') { gchar *c; if (ch == '"') c = g_strdup ("\""); else c = g_strdup ("'"); ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (editor), NULL); insert_editor_blocked (editor, iter, c, plugin); ianjuta_editor_goto_position (editor, iter, NULL); ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (editor), NULL); g_free (c); } g_object_unref (previous); g_object_unref (iter); return; } g_object_unref (previous); } } g_object_unref (iter); }
static void rb_iradio_source_constructed (GObject *object) { RBIRadioSource *source; RBShell *shell; GtkAction *action; GSettings *settings; GtkUIManager *ui_manager; GtkWidget *grid; GtkWidget *paned; RBSourceToolbar *toolbar; gint size; GdkPixbuf *pixbuf; RB_CHAIN_GOBJECT_METHOD (rb_iradio_source_parent_class, constructed, object); source = RB_IRADIO_SOURCE (object); paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); g_object_get (source, "shell", &shell, NULL); g_object_get (shell, "db", &source->priv->db, "shell-player", &source->priv->player, "ui-manager", &ui_manager, NULL); g_object_unref (shell); gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL); pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), IRADIO_SOURCE_ICON, size, 0, NULL); g_object_set (source, "pixbuf", pixbuf, NULL); if (pixbuf != NULL) { g_object_unref (pixbuf); } settings = g_settings_new ("org.gnome.rhythmbox.plugins.iradio"); if (g_settings_get_boolean (settings, "initial-stations-loaded") == FALSE) { GObject *plugin; char *file; g_object_get (source, "plugin", &plugin, NULL); file = rb_find_plugin_data_file (plugin, "iradio-initial.xspf"); if (file != NULL) { char *uri = g_filename_to_uri (file, NULL, NULL); if (uri != NULL) { rb_iradio_source_add_from_playlist (source, uri); g_free (uri); g_settings_set_boolean (settings, "initial-stations-loaded", TRUE); } } g_free (file); g_object_unref (plugin); } source->priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source), "IRadioActions", rb_iradio_source_actions, G_N_ELEMENTS (rb_iradio_source_actions), source); action = gtk_action_group_get_action (source->priv->action_group, "MusicNewInternetRadioStation"); /* Translators: this is the toolbar button label for New Internet Radio Station action. */ g_object_set (action, "short-label", C_("Radio", "Add"), NULL); /* set up stations view */ source->priv->stations = rb_entry_view_new (source->priv->db, G_OBJECT (source->priv->player), FALSE, FALSE); rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_TITLE, TRUE); rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_GENRE, FALSE); /* rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_QUALITY, FALSE); */ rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_RATING, FALSE); /* rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);*/ rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_LAST_PLAYED, FALSE); g_signal_connect_object (source->priv->stations, "notify::sort-order", G_CALLBACK (rb_iradio_source_songs_view_sort_order_changed_cb), source, 0); /* set up drag and drop for the song tree view. * we don't use RBEntryView's DnD support because it does too much. * we just want to be able to drop stations in to add them. */ g_signal_connect_object (source->priv->stations, "drag_data_received", G_CALLBACK (stations_view_drag_data_received_cb), source, 0); gtk_drag_dest_set (GTK_WIDGET (source->priv->stations), GTK_DEST_DEFAULT_ALL, stations_view_drag_types, 2, GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect_object (source->priv->stations, "show_popup", G_CALLBACK (rb_iradio_source_songs_show_popup_cb), source, 0); /* set up genre entry view */ source->priv->genres = rb_property_view_new (source->priv->db, RHYTHMDB_PROP_GENRE, _("Genre")); gtk_widget_show_all (GTK_WIDGET (source->priv->genres)); gtk_widget_set_no_show_all (GTK_WIDGET (source->priv->genres), TRUE); g_signal_connect_object (source->priv->genres, "property-selected", G_CALLBACK (genre_selected_cb), source, 0); g_signal_connect_object (source->priv->genres, "property-selection-reset", G_CALLBACK (genre_selection_reset_cb), source, 0); g_object_set (source->priv->genres, "vscrollbar_policy", GTK_POLICY_AUTOMATIC, NULL); gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (source->priv->genres), FALSE, FALSE); gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (source->priv->stations), TRUE, FALSE); /* set up toolbar */ toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager); rb_source_toolbar_add_search_entry (toolbar, NULL, _("Search your internet radio stations")); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 6); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_widget_set_margin_top (GTK_WIDGET (grid), 6); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (toolbar), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), paned, 0, 1, 1, 1); gtk_container_add (GTK_CONTAINER (source), grid); rb_source_bind_settings (RB_SOURCE (source), GTK_WIDGET (source->priv->stations), paned, GTK_WIDGET (source->priv->genres)); gtk_widget_show_all (GTK_WIDGET (source)); g_signal_connect_object (source->priv->player, "playing-source-changed", G_CALLBACK (playing_source_changed_cb), source, 0); source->priv->default_search = rb_iradio_source_search_new (); rb_iradio_source_do_query (source); }
/* incomplete_statement: * 1 == COMPLETE STATEMENT * 0 == INCOMPLETE STATEMENT * -1 == UNKNOWN */ static gint get_line_indentation_base (IndentCPlugin *plugin, IAnjutaEditor *editor, gint line_num, gint *incomplete_statement, gint *parenthesis_indentation, gboolean *colon_indent) { IAnjutaIterable *iter; gchar point_ch; gint line_indent = 0; gint extra_indent = 0; gboolean looking_at_just_next_line = TRUE; gboolean current_line_is_preprocessor = FALSE; gboolean current_line_is_continuation = FALSE; gboolean line_checked_for_comment = FALSE; /* Determine whether or not to add multi-line comment asterisks */ const gchar *comment_continued = " * "; IAnjutaIterable *line_begin = ianjuta_editor_get_line_begin_position (editor, line_num, NULL); IAnjutaIterable *line_end = ianjuta_editor_get_line_end_position (editor, line_num, NULL); *incomplete_statement = -1; *parenthesis_indentation = 0; if (line_num <= 1) return 0; /* DEBUG_PRINT ("In %s()", __FUNCTION__); */ iter = ianjuta_editor_get_line_begin_position (editor, line_num, NULL); current_line_is_preprocessor = line_is_preprocessor (editor, iter); current_line_is_continuation = line_is_continuation (editor, iter); /* DEBUG_PRINT ("Current line is preprocessor = %d", current_line_is_preprocessor); DEBUG_PRINT ("Current line is continuation = %d", current_line_is_continuation); */ /* line_indent = get_line_indentation (editor, line_num - 1); */ if (current_line_is_preprocessor && current_line_is_continuation) { /* Continuation of preprocessor line -- just maintain indentation */ g_object_unref (iter); return get_line_indentation (editor, line_num - 1); } else if (current_line_is_preprocessor) { /* Preprocessor line -- indentation should be 0 */ g_object_unref (iter); return 0; } while (ianjuta_iterable_previous (iter, NULL)) { /* Skip strings */ IAnjutaEditorAttribute attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter), NULL); if (attrib == IANJUTA_EDITOR_STRING) continue; point_ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL); /* DEBUG_PRINT("point_ch = %c", point_ch); */ /* Check for line comment comment */ if (!line_checked_for_comment && !isspace(point_ch)) { gboolean comment = FALSE; IAnjutaIterable* new_iter = ianjuta_iterable_clone (iter, NULL); do { gchar c; /* Skip strings */ if (ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (new_iter), NULL) == IANJUTA_EDITOR_STRING) continue; c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (new_iter), 0, NULL); if (iter_is_newline (new_iter, c)) { line_checked_for_comment = TRUE; break; } if (c == '/') { IAnjutaIterable* tmp_iter = ianjuta_iterable_clone (new_iter, NULL); if (!ianjuta_iterable_previous (tmp_iter, NULL)) { g_object_unref (tmp_iter); break; } c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (tmp_iter), 0, NULL); if (c == '/') { /* is a line comment, skip until begin of comment */ comment = TRUE; g_object_unref (tmp_iter); break; } g_object_unref (tmp_iter); } } while (ianjuta_iterable_previous (new_iter, NULL)); if (comment) { ianjuta_iterable_assign (iter, new_iter, NULL); ianjuta_iterable_previous (iter, NULL); g_object_unref (new_iter); continue; } g_object_unref (new_iter); } /* Check if we are inside a comment */ if (point_ch == '/' || point_ch == '*') { gboolean comment = FALSE; gboolean comment_end = FALSE; IAnjutaIterable* new_iter = ianjuta_iterable_clone (iter, NULL); do { gchar c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(new_iter), 0, NULL); if (!comment_end && iter_is_newline (new_iter, c)) { break; } if (c == '*') { IAnjutaIterable* prev = ianjuta_iterable_clone (new_iter, NULL); IAnjutaIterable* next = ianjuta_iterable_clone (new_iter, NULL); ianjuta_iterable_previous (prev, NULL); ianjuta_iterable_next (next, NULL); gchar prev_c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (prev), 0, NULL); gchar next_c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (next), 0, NULL); if (prev_c == '/') { /* starts comment */ comment = TRUE; if (!comment_end) { extra_indent++; /* If a multiline comment is continuing, check the next line and insert " * " * only if it does not already exist there. The purpose of this fix is to avoid * extra " * " on auto-indent. */ if ((g_settings_get_boolean (plugin->settings, PREF_COMMENT_LEADING_ASTERISK)) && (ianjuta_iterable_compare (line_end, line_begin, NULL)) == 0) { ianjuta_editor_insert (editor, line_begin, comment_continued, -1, NULL); } /* In the middle of a comment we can't know * if the statement is incomplete */ *incomplete_statement = -1; /* ":" have to be ignored inside comments */ if (*colon_indent) { *colon_indent = FALSE; extra_indent -= INDENT_SIZE; } } g_object_unref (prev); g_object_unref (next); break; } else if (next_c == '/') { /* ends comment: */ comment_end = TRUE; g_object_unref (prev); g_object_unref (next); continue; } /* Possibly continued comment */ else if (isspace(prev_c)) { gboolean possible_comment = FALSE; while (ianjuta_iterable_previous (prev, NULL)) { prev_c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (prev), 0, NULL); if (!isspace(prev_c)) break; if (iter_is_newline (prev, prev_c)) { possible_comment = TRUE; break; } } if (possible_comment) { ianjuta_iterable_assign (new_iter, prev, NULL); g_object_unref (prev); g_object_unref (next); continue; } } g_object_unref (prev); g_object_unref (next); } } while (ianjuta_iterable_previous (new_iter, NULL)); if (comment) { ianjuta_iterable_assign (iter, new_iter, NULL); ianjuta_iterable_previous (iter, NULL); g_object_unref (new_iter); continue; } g_object_unref (new_iter); } if (point_ch == ')' || point_ch == ']' || point_ch == '}') { gint line_saved; line_saved = ianjuta_editor_get_line_from_position (editor, iter, NULL); /* If we encounter a block-end before anything else, the * statement could hardly be incomplte. */ if (point_ch == '}' && *incomplete_statement == -1) *incomplete_statement = 0; /* If at level 0 indentation, encoutered a * block end, don't bother going further */ if (point_ch == '}' && get_line_indentation (editor, line_saved) <= 0) { line_indent = 0; line_indent += extra_indent; break; } /* Find matching brace and continue */ if (!anjuta_util_jump_to_matching_brace (iter, point_ch, -1)) { line_indent = get_line_indentation (editor, line_saved); line_indent += extra_indent; break; } } else if (point_ch == '{') { gint line_for_indent = ianjuta_editor_get_line_from_position (editor, iter, NULL); line_indent = get_line_indentation (editor, line_for_indent); /* Increase line indentation */ line_indent += INDENT_SIZE; line_indent += extra_indent; /* If we encounter a block-start before anything else, the * statement could hardly be incomplte. */ if (point_ch == '{' && *incomplete_statement == -1) *incomplete_statement = 0; break; } else if (point_ch == '(' || point_ch == '[') { line_indent = 0; if (g_settings_get_boolean (plugin->settings, PREF_INDENT_PARENTHESIS_LINEUP)) { while (ianjuta_iterable_previous (iter, NULL)) { gchar dummy_ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL); if (iter_is_newline (iter, dummy_ch)) { skip_iter_to_newline_head (iter, dummy_ch); break; } if (dummy_ch == '\t') line_indent += TAB_SIZE; else (*parenthesis_indentation)++; } (*parenthesis_indentation)++; line_indent += extra_indent; } else { gint line_for_indent = ianjuta_editor_get_line_from_position (editor, iter, NULL); line_indent = get_line_indentation (editor, line_for_indent); line_indent += extra_indent; (*parenthesis_indentation) += g_settings_get_int (plugin->settings, PREF_INDENT_PARENTHESIS_SIZE); } /* Although statement is incomplete at this point, we don't * set it to incomplete and just leave it to unknown to avaoid * increating indentation for it, because incomplete braces, * overrides any existing indentation */ *incomplete_statement = -1; break; } else if (point_ch == ';' || point_ch == ',') { /* If we encounter statement-end before any non-whitespace * char, the statement is complete. */ if (*incomplete_statement == -1) *incomplete_statement = 0; } else if (point_ch == ':' && *colon_indent == FALSE) { /* This is a forward reference, all lines below should have * increased indentation until the next statement has * a ':' * If current line indentation is zero, that we don't indent */ IAnjutaIterable* new_iter = ianjuta_iterable_clone (iter, NULL); IAnjutaIterable* line_begin; gboolean indent = FALSE; gchar c; /* Is the last non-whitespace in line */ while (ianjuta_iterable_next (new_iter, NULL)) { c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (new_iter), 0, NULL); if (!isspace(c)) break; if (iter_is_newline (new_iter, c)) { indent = TRUE; break; } } line_begin = ianjuta_editor_get_line_begin_position(editor, ianjuta_editor_get_line_from_position(editor, iter, NULL), NULL); c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (line_begin), 0, NULL); if (indent) { *colon_indent = TRUE; if (*incomplete_statement == -1) *incomplete_statement = 0; } if (indent && isspace(c)) { extra_indent += INDENT_SIZE; } g_object_unref (new_iter); g_object_unref (line_begin); } else if (iter_is_newline (iter, point_ch)) { skip_iter_to_newline_head (iter, point_ch); /* We just crossed a line boundary. Skip any preprocessor lines, * and ensure that line_indent is updated with correct real * previous non-preprocessor line. */ if (skip_preprocessor_lines (editor, iter) && looking_at_just_next_line) { /* gint line = ianjuta_editor_get_line_from_position (editor, iter, NULL); line_indent = get_line_indentation (editor, line); */ } looking_at_just_next_line = FALSE; line_checked_for_comment = FALSE; } else if (!isspace (point_ch)) { /* If we encounter any non-whitespace char before any of the * statement-complete indicators, the statement is basically * incomplete */ if (*incomplete_statement == -1) *incomplete_statement = 1; } } if (!line_indent && extra_indent) { line_indent += extra_indent; } g_object_unref (iter); return line_indent; }
static void random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget) { gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key)); }
gboolean gs_plugin_add_distro_upgrades (GsPlugin *plugin, GsAppList *list, GCancellable *cancellable, GError **error) { GsPluginData *priv = gs_plugin_get_data (plugin); gsize len; guint i; g_autofree gchar *data = NULL; g_autoptr(GPtrArray) distros = NULL; g_autoptr(GSettings) settings = NULL; /* just ensure there is any data, no matter how old */ if (!gs_plugin_fedora_distro_upgrades_refresh (plugin, G_MAXUINT, cancellable, error)) return FALSE; /* get cached file */ if (!g_file_get_contents (priv->cachefn, &data, &len, error)) { gs_utils_error_convert_gio (error); return FALSE; } /* parse data */ settings = g_settings_new ("org.gnome.software"); distros = parse_pkgdb_collections_data (data, (gssize) len, error); if (distros == NULL) return FALSE; g_ptr_array_sort (distros, sort_distros_cb); for (i = 0; i < distros->len; i++) { DistroInfo *distro_info = g_ptr_array_index (distros, i); g_autofree gchar *app_id = NULL; g_autofree gchar *app_version = NULL; g_autofree gchar *background = NULL; g_autofree gchar *cache_key = NULL; g_autofree gchar *url = NULL; g_autofree gchar *css = NULL; g_autoptr(GsApp) app = NULL; g_autoptr(AsIcon) ic = NULL; /* only interested in upgrades to the same distro */ if (g_strcmp0 (distro_info->name, priv->os_name) != 0) continue; /* only interested in newer versions, but not more than N+2 */ if (distro_info->version <= priv->os_version || distro_info->version > priv->os_version + 2) continue; /* only interested in non-devel distros */ if (!g_settings_get_boolean (settings, "show-upgrade-prerelease")) { if (distro_info->status == DISTRO_STATUS_DEVEL) continue; } /* search in the cache */ cache_key = g_strdup_printf ("release-%u", distro_info->version); app = gs_plugin_cache_lookup (plugin, cache_key); if (app != NULL) { gs_app_list_add (list, app); continue; } app_id = g_strdup_printf ("org.fedoraproject.release-%u.upgrade", distro_info->version); app_version = g_strdup_printf ("%u", distro_info->version); /* icon from disk */ ic = as_icon_new (); as_icon_set_kind (ic, AS_ICON_KIND_LOCAL); as_icon_set_filename (ic, "/usr/share/pixmaps/fedora-logo-sprite.png"); /* create */ app = gs_app_new (app_id); gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE); gs_app_set_state (app, AS_APP_STATE_AVAILABLE); gs_app_set_name (app, GS_APP_QUALITY_LOWEST, distro_info->name); gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, /* TRANSLATORS: this is a title for Fedora distro upgrades */ _("A major upgrade, with new features and added polish.")); gs_app_set_description (app, GS_APP_QUALITY_LOWEST, "Fedora Workstation is a polished, " "easy to use operating system for " "laptop and desktop computers, with a " "complete set of tools for developers " "and makers of all kinds."); gs_app_set_version (app, app_version); gs_app_set_size_installed (app, 1024 * 1024 * 1024); /* estimate */ gs_app_set_size_download (app, 256 * 1024 * 1024); /* estimate */ gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "LicenseRef-free"); gs_app_add_quirk (app, AS_APP_QUIRK_NEEDS_REBOOT); gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE); gs_app_add_quirk (app, AS_APP_QUIRK_NOT_REVIEWABLE); gs_app_set_origin_ui (app, distro_info->name); gs_app_add_icon (app, ic); gs_app_set_management_plugin (app, "packagekit"); /* show a Fedora magazine article for the release */ url = g_strdup_printf ("https://fedoramagazine.org/whats-new-fedora-%u-workstation", distro_info->version); gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url); /* use a fancy background */ background = get_upgrade_css_background (distro_info->version); css = g_strdup_printf ("background: %s;" "background-position: center;" "background-size: cover;", background); gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css", css); gs_app_list_add (list, app); /* save in the cache */ gs_plugin_cache_add (plugin, cache_key, app); } return TRUE; }