static void remove_button_clicked (GtkButton *button, CcBackgroundPanel *panel) { CcBackgroundItem *item; GtkListStore *store; GtkTreePath *path; CcBackgroundPanelPrivate *priv; priv = panel->priv; item = get_selected_item (panel); if (item == NULL) g_assert_not_reached (); bg_pictures_source_remove (panel->priv->pictures_source, item); g_object_unref (item); /* Are there any items left in the pictures tree store? */ store = bg_source_get_liststore (BG_SOURCE (panel->priv->pictures_source)); if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 0) gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("sources-combobox")), SOURCE_WALLPAPERS); path = gtk_tree_path_new_from_string ("0"); gtk_icon_view_select_path (GTK_ICON_VIEW (WID ("backgrounds-iconview")), path); gtk_tree_path_free (path); }
static void wp_props_wp_selected (GtkTreeSelection *selection, AppearanceData *data) { MateWPItem *item; item = get_selected_item (data, NULL); if (item != NULL) { wp_set_sensitivities (data); if (strcmp (item->filename, "(none)") != 0) wp_option_menu_set (data, item->options, FALSE); wp_option_menu_set (data, item->shade_type, TRUE); gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor); gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor); if (data->wp_update_settings) wp_props_wp_set (data, item); } else { gtk_widget_set_sensitive (data->wp_rem_button, FALSE); } }
static void wp_shade_type_changed (GtkWidget *combobox, AppearanceData *data) { MateWPItem *item; GtkTreeIter iter; GdkPixbuf *pixbuf; item = get_selected_item (data, &iter); if (item == NULL) return; item->shade_type = gtk_combo_box_get_active (GTK_COMBO_BOX (data->wp_color_menu)); pixbuf = mate_wp_item_get_thumbnail (item, data->thumb_factory, data->thumb_width, data->thumb_height); gtk_list_store_set (GTK_LIST_STORE (data->wp_model), &iter, 0, pixbuf, -1); if (pixbuf != NULL) g_object_unref (pixbuf); if (g_settings_is_writable (data->wp_settings, WP_SHADING_KEY)) g_settings_set_enum (data->wp_settings, WP_SHADING_KEY, item->shade_type); }
static void wp_color_changed (AppearanceData *data, gboolean update) { MateWPItem *item; item = get_selected_item (data, NULL); if (item == NULL) return; gtk_color_button_get_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor); gtk_color_button_get_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor); if (update) { gchar *pcolor, *scolor; pcolor = gdk_color_to_string (item->pcolor); scolor = gdk_color_to_string (item->scolor); g_settings_set_string (data->wp_settings, WP_PCOLOR_KEY, pcolor); g_settings_set_string (data->wp_settings, WP_SCOLOR_KEY, scolor); g_free (pcolor); g_free (scolor); } wp_shade_type_changed (NULL, data); }
static void buttons_cell_data_func (GtkCellLayout *layout, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { AppearanceData *data = user_data; GtkTreePath *path; MateWPItem *item; gboolean visible; path = gtk_tree_model_get_path (model, iter); if (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (layout), path)) { item = get_selected_item (data, NULL); visible = mate_bg_changes_with_time (item->bg); } else visible = FALSE; g_object_set (G_OBJECT (cell), "visible", visible, NULL); gtk_tree_path_free (path); }
void tvertical_list::handle_key_down_arrow(SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(size_t i = get_ordered_index(get_selected_item()) + 1; i < get_item_count(); ++i) { // why do we do this check here but not in handle_key_up_arrow? if(item_ordered(i).get_visible() == twidget::tvisible::invisible || !get_item_shown(get_item_at_ordered(i))) { continue; } // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0)); if(control && control->get_active()) { select_item(get_item_at_ordered(i), true); return; } } }
static void wp_options_changed (GSettings *settings, gchar *key, AppearanceData *data) { MateWPItem *item; gchar *option; option = g_settings_get_string (settings, key); /* "none" means we don't use a background image */ if (option == NULL || !strcmp (option, "none")) { /* temporarily disconnect so we don't override settings when * updating the selection */ data->wp_update_settings = FALSE; wp_uri_changed ("(none)", data); data->wp_update_settings = TRUE; if (option) g_free (option); return; } item = get_selected_item (data, NULL); if (item != NULL) { item->options = g_settings_get_enum (settings, key); wp_option_menu_set (data, item->options, FALSE); } g_free (option); }
void thorizontal_list::handle_key_right_arrow( SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) { if(item(i).get_visible() == twidget::INVISIBLE || !get_item_shown(i)) { continue; } // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item(i).widget(0, 0)); if(control && control->get_active()) { select_item(i); return; } } }
void event_mouse_move(vsx_widget_distance distance, vsx_widget_coords coords) { VSX_UNUSED(distance); if (get_selected_item() != "") { dragging = true; drag_coords = coords; } }
const twidget* tindependent::find_at(const tpoint& coordinate, const bool must_be_active) const { assert(get_window()); const int selected_item = get_selected_item(); if(selected_item < 0) { return NULL; } const tgrid& grid = item(selected_item); return grid.find_at(coordinate, must_be_active); }
void event_mouse_down(vsx_widget_distance distance,vsx_widget_coords coords,int button) { VSX_UNUSED(distance); VSX_UNUSED(coords); VSX_UNUSED(button); if (dragging) dragging = false; if (get_selected_item() != "") { command_q_b.add_raw("seq_pool select " + editor->get_line(editor->selected_line) ); parent->vsx_command_queue_b(this); } }
static void wp_select_after_realize (GtkWidget *widget, AppearanceData *data) { MateWPItem *item; g_idle_add (wp_load_stuffs, data); item = get_selected_item (data, NULL); if (item == NULL) item = g_hash_table_lookup (data->wp_hash, "(none)"); select_item (data, item, TRUE); }
static void wp_shading_changed (GSettings *settings, gchar *key, AppearanceData *data) { MateWPItem *item; wp_set_sensitivities (data); item = get_selected_item (data, NULL); if (item != NULL) { item->shade_type = g_settings_get_enum (settings, key); wp_option_menu_set (data, item->shade_type, TRUE); } }
static void next_frame (AppearanceData *data, GtkCellRenderer *cr, gint direction) { MateWPItem *item; GtkTreeIter iter; GdkPixbuf *pixbuf, *pb; gint frame; pixbuf = NULL; frame = data->frame + direction; item = get_selected_item (data, &iter); if (frame >= 0) pixbuf = mate_wp_item_get_frame_thumbnail (item, data->thumb_factory, data->thumb_width, data->thumb_height, frame); if (pixbuf) { gtk_list_store_set (GTK_LIST_STORE (data->wp_model), &iter, 0, pixbuf, -1); g_object_unref (pixbuf); data->frame = frame; } pb = buttons[1]; if (direction < 0) { if (frame == 0) pb = buttons[0]; } else { pixbuf = mate_wp_item_get_frame_thumbnail (item, data->thumb_factory, data->thumb_width, data->thumb_height, frame + 1); if (pixbuf) g_object_unref (pixbuf); else pb = buttons[2]; } g_object_set (cr, "pixbuf", pb, NULL); }
static void wp_uri_changed (const gchar *uri, AppearanceData *data) { MateWPItem *item, *selected; item = g_hash_table_lookup (data->wp_hash, uri); selected = get_selected_item (data, NULL); if (selected != NULL && strcmp (selected->filename, uri) != 0) { if (item == NULL) item = wp_add_image (data, uri); if (item) select_item (data, item, TRUE); } }
void tvertical_list::handle_key_up_arrow(SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(int i = get_ordered_index(get_selected_item()) - 1; i >= 0; --i) { // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0)); if(control && control->get_active()) { select_item(get_item_at_ordered(i), true); return; } } }
static void wp_drag_get_data (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint type, guint time, AppearanceData *data) { if (type == TARGET_URI_LIST) { MateWPItem *item = get_selected_item (data, NULL); if (item != NULL) { char *uris[2]; uris[0] = g_filename_to_uri (item->filename, NULL, NULL); uris[1] = NULL; gtk_selection_data_set_uris (selection_data, uris); g_free (uris[0]); } } }
static void wp_set_sensitivities (AppearanceData *data) { MateWPItem *item; gchar *filename = NULL; item = get_selected_item (data, NULL); if (item != NULL) filename = item->filename; if (!g_settings_is_writable (data->wp_settings, WP_OPTIONS_KEY) || (filename && !strcmp (filename, "(none)"))) gtk_widget_set_sensitive (data->wp_style_menu, FALSE); else gtk_widget_set_sensitive (data->wp_style_menu, TRUE); if (!g_settings_is_writable (data->wp_settings, WP_SHADING_KEY)) gtk_widget_set_sensitive (data->wp_color_menu, FALSE); else gtk_widget_set_sensitive (data->wp_color_menu, TRUE); if (!g_settings_is_writable (data->wp_settings, WP_PCOLOR_KEY)) gtk_widget_set_sensitive (data->wp_pcpicker, FALSE); else gtk_widget_set_sensitive (data->wp_pcpicker, TRUE); if (!g_settings_is_writable (data->wp_settings, WP_SCOLOR_KEY)) gtk_widget_set_sensitive (data->wp_scpicker, FALSE); else gtk_widget_set_sensitive (data->wp_scpicker, TRUE); if (!filename || !strcmp (filename, "(none)")) gtk_widget_set_sensitive (data->wp_rem_button, FALSE); else gtk_widget_set_sensitive (data->wp_rem_button, TRUE); }
static void wp_remove_wallpaper (GtkWidget *widget, AppearanceData *data) { MateWPItem *item; GtkTreeIter iter; GtkTreePath *path; item = get_selected_item (data, &iter); if (item) { item->deleted = TRUE; if (gtk_list_store_remove (GTK_LIST_STORE (data->wp_model), &iter)) path = gtk_tree_model_get_path (data->wp_model, &iter); else path = gtk_tree_path_new_first (); gtk_icon_view_select_path (data->wp_view, path); gtk_icon_view_set_cursor (data->wp_view, path, NULL, FALSE); gtk_tree_path_free (path); } }
static void backgrounds_changed_cb (GtkIconView *icon_view, CcBackgroundPanel *panel) { GtkTreeIter iter; GtkTreeModel *model; CcBackgroundItem *item; CcBackgroundPanelPrivate *priv = panel->priv; char *pcolor, *scolor; gboolean draw_preview = TRUE; const char *uri; CcBackgroundItemFlags flags; char *filename; item = get_selected_item (panel); if (item == NULL) return; /* Update current source */ model = gtk_combo_box_get_model (GTK_COMBO_BOX (WID ("sources-combobox"))); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("sources-combobox")), &iter); gtk_tree_model_get (model, &iter, COL_SOURCE_TYPE, &priv->current_source, -1); uri = cc_background_item_get_uri (item); flags = cc_background_item_get_flags (item); if ((flags & CC_BACKGROUND_ITEM_HAS_URI) && uri == NULL) { g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, G_DESKTOP_BACKGROUND_STYLE_NONE); g_settings_set_string (priv->settings, WP_URI_KEY, ""); } else if (cc_background_item_get_source_url (item) != NULL && cc_background_item_get_needs_download (item)) { GFile *source, *dest; gchar *cache_path, *basename, *dest_path, *display_name, *dest_uri; GdkPixbuf *pixbuf; cache_path = bg_pictures_source_get_cache_path (); if (g_mkdir_with_parents (cache_path, 0755) < 0) { g_warning ("Failed to create directory '%s'", cache_path); g_free (cache_path); return; } g_free (cache_path); dest_path = bg_pictures_source_get_unique_path (cc_background_item_get_source_url (item)); dest = g_file_new_for_path (dest_path); g_free (dest_path); source = g_file_new_for_uri (cc_background_item_get_source_url (item)); basename = g_file_get_basename (source); display_name = g_filename_display_name (basename); dest_path = g_file_get_path (dest); g_free (basename); /* create a blank image to use until the source image is ready */ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); gdk_pixbuf_fill (pixbuf, 0x00000000); gdk_pixbuf_save (pixbuf, dest_path, "png", NULL, NULL); g_object_unref (pixbuf); g_free (dest_path); if (priv->copy_cancellable) { g_cancellable_cancel (priv->copy_cancellable); g_cancellable_reset (priv->copy_cancellable); } if (priv->spinner) { gtk_widget_destroy (GTK_WIDGET (priv->spinner)); priv->spinner = NULL; } /* create a spinner while the file downloads */ priv->spinner = gtk_spinner_new (); gtk_spinner_start (GTK_SPINNER (priv->spinner)); gtk_box_pack_start (GTK_BOX (WID ("bottom-hbox")), priv->spinner, FALSE, FALSE, 6); gtk_widget_show (priv->spinner); /* reference the panel in case it is removed before the copy is * finished */ g_object_ref (panel); g_object_set_data_full (G_OBJECT (source), "item", g_object_ref (item), g_object_unref); g_file_copy_async (source, dest, G_FILE_COPY_OVERWRITE, G_PRIORITY_DEFAULT, priv->copy_cancellable, NULL, NULL, copy_finished_cb, panel); g_object_unref (source); dest_uri = g_file_get_uri (dest); g_object_unref (dest); g_settings_set_string (priv->settings, WP_URI_KEY, dest_uri); g_object_set (G_OBJECT (item), "uri", dest_uri, "needs-download", FALSE, "name", display_name, NULL); g_free (display_name); g_free (dest_uri); /* delay the updated drawing of the preview until the copy finishes */ draw_preview = FALSE; } else { g_settings_set_string (priv->settings, WP_URI_KEY, uri); } /* Also set the placement if we have a URI and the previous value was none */ if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT) { g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item)); } else if (uri != NULL) { GDesktopBackgroundStyle style; style = g_settings_get_enum (priv->settings, WP_OPTIONS_KEY); if (style == G_DESKTOP_BACKGROUND_STYLE_NONE) g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item)); } if (flags & CC_BACKGROUND_ITEM_HAS_SHADING) g_settings_set_enum (priv->settings, WP_SHADING_KEY, cc_background_item_get_shading (item)); /* When changing to a background with colours set, * don't overwrite what's in GSettings, but read * from it instead. * We have a hack for the colors source though */ if (flags & CC_BACKGROUND_ITEM_HAS_PCOLOR && priv->current_source != SOURCE_COLORS) { g_settings_set_string (priv->settings, WP_PCOLOR_KEY, cc_background_item_get_pcolor (item)); } else { pcolor = g_settings_get_string (priv->settings, WP_PCOLOR_KEY); g_object_set (G_OBJECT (item), "primary-color", pcolor, NULL); } if (flags & CC_BACKGROUND_ITEM_HAS_SCOLOR && priv->current_source != SOURCE_COLORS) { g_settings_set_string (priv->settings, WP_SCOLOR_KEY, cc_background_item_get_scolor (item)); } else { scolor = g_settings_get_string (priv->settings, WP_SCOLOR_KEY); g_object_set (G_OBJECT (item), "secondary-color", scolor, NULL); } /* Apply all changes */ g_settings_apply (priv->settings); update_remove_button (panel, item); /* update the preview information */ if (draw_preview != FALSE) { update_preview (priv, item); /* Save the source XML if there is one */ filename = get_save_path (); if (create_save_dir ()) cc_background_xml_save (priv->current_background, filename); } }