void on_list_del_clicked(GtkButton *button, gpointer user_data) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); ASImageListEntry *entry = asgtk_image_dir_get_selection( id ); if( entry ) { if( asgtk_yes_no_question1( WallpaperState.main_window, "Do you really want to delete private background file \"%s\" ???", entry->name ) ) { if( id->mini_extension ) { char *mini_filename, *mini_fullfilename ; asgtk_image_dir_make_mini_names( id, entry->name, &mini_filename, &mini_fullfilename ); if( CheckFile( mini_fullfilename ) == 0 ) { if( asgtk_yes_no_question1( WallpaperState.main_window, "It appears that there is a minipixmap for deleted background with the name \"%s\". Would you like to delete it as well ?", mini_filename ) ) { unlink( mini_fullfilename ); } } free( mini_fullfilename ); free( mini_filename ); } unlink( entry->fullfilename ); asgtk_info2( WallpaperState.main_window, "Background image \"%s\" deleted.", entry->name, NULL ); asgtk_image_dir_refresh( id ); } unref_asimage_list_entry( entry ); } }
static void asgtk_image_view_dispose (GObject * object) { ASGtkImageView *iv = ASGTK_IMAGE_VIEW (object); unref_asimage_list_entry (iv->image_entry); iv->image_entry = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); }
void on_list_apply_clicked(GtkButton *button, gpointer user_data) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); ASImageListEntry *entry = asgtk_image_dir_get_selection( id ); if( entry ) { SendTextCommand ( F_CHANGE_BACKGROUND, NULL, entry->fullfilename, 0); unref_asimage_list_entry( entry ); } }
void on_backgrounds_dir_changed( ASGtkXMLView *xv, gpointer user_data, Bool new_file) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); if( new_file ) asgtk_image_dir_refresh( id ); else { ASImageListEntry *le = asgtk_image_dir_get_selection( id ); asgtk_image_view_set_entry ( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), le); unref_asimage_list_entry( le ); } }
static void filelist_sel_handler(ASGtkImageDir *id, gpointer user_data) { ASFileBrowserMainFrame *data = (ASFileBrowserMainFrame *)user_data; if( data ) { ASImageListEntry *le = asgtk_image_dir_get_selection( id ); if( le ) { if( le->type != ASIT_XMLScript ) { gtk_widget_hide( data->view_xml ); asgtk_xml_view_set_entry ( ASGTK_XML_VIEW(data->view_xml), NULL ); }else { gtk_widget_show( data->view_xml ); asgtk_xml_view_set_entry ( ASGTK_XML_VIEW(data->view_xml), le ); } if( le->type == ASIT_Unknown ) { gtk_widget_hide( data->view_image ); asgtk_image_view_set_entry ( ASGTK_IMAGE_VIEW(data->view_image), NULL); }else { gtk_widget_show( data->view_image ); asgtk_image_view_set_entry ( ASGTK_IMAGE_VIEW(data->view_image), le); } load_asimage_list_entry_data( le, DEFAULT_MAX_TEXT_SIZE ); if( !get_flags( le->buffer->flags, ASILEB_Binary) ) { /* use text view */ gtk_widget_show( data->view_text_win ); gtk_widget_hide( data->view_hex_win ); gtk_text_buffer_set_text( data->text_buffer, le->buffer->data, le->buffer->size ); gtk_text_view_set_buffer( GTK_TEXT_VIEW(data->view_text), data->text_buffer ); }else { /* use hex view */ gtk_widget_show( data->view_hex_win ); gtk_widget_hide( data->view_text_win ); gtk_text_view_set_buffer( GTK_TEXT_VIEW(data->view_hex), data->text_buffer ); } unref_asimage_list_entry( le ); } } }
static void backs_list_sel_handler(ASGtkImageDir *id, gpointer user_data) { ASGtkImageView *iv = ASGTK_IMAGE_VIEW(user_data); ASImageListEntry *le; g_return_if_fail (ASGTK_IS_IMAGE_DIR (id)); le = asgtk_image_dir_get_selection( id ); asgtk_image_view_set_entry ( iv, le); if( le != NULL ) { if( WallpaperState.xml_editor && le->type == ASIT_XMLScript ) asgtk_xml_editor_set_entry( ASGTK_XML_EDITOR( WallpaperState.xml_editor), le ); if( iv ) { char *mini_fullname = NULL ; Bool has_mini = False ; if( le->type == ASIT_XMLScript ) { gtk_widget_show(WallpaperState.edit_xml_button); gtk_widget_hide(WallpaperState.make_xml_button); }else { gtk_widget_hide(WallpaperState.edit_xml_button); gtk_widget_show(WallpaperState.make_xml_button); } if( asgtk_image_dir_make_mini_names( id, le->name, NULL, &mini_fullname ) ) { has_mini = ( CheckFile( mini_fullname ) == 0 ); free( mini_fullname ); } if( has_mini ) { gtk_button_set_label(GTK_BUTTON(WallpaperState.make_mini_button), "Update mini"); }else { gtk_button_set_label(GTK_BUTTON(WallpaperState.make_mini_button), "Make mini"); } } unref_asimage_list_entry( le ); } }
void make_xml_dlg_destroy(ASGtkMakeXMLDlg *mx) { if( mx ) { gtk_widget_destroy( mx->dlg ); if( mx->entry ) { unref_asimage_list_entry( mx->entry ); mx->entry = NULL ; } if( mx->fullfilename ) free( mx->fullfilename ); if( mx->mini_fullfilename ) free( mx->mini_fullfilename ); memset( mx, 0x00, sizeof(ASGtkMakeXMLDlg)); free( mx ); } }
void on_list_add_clicked(GtkButton *button, gpointer user_data) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); ASImageListEntry *entry = asgtk_image_dir_get_selection( id ); if( entry ) { ASGtkImageDir *backs_list = ASGTK_IMAGE_DIR(WallpaperState.backs_list); char *new_filename = make_file_name( backs_list->fulldirname, entry->name ); if( CheckFile( new_filename ) == 0 ) { if( !asgtk_yes_no_question1( WallpaperState.main_window, "Private background with the name \"%s\" already exists. Would you like to replace it ???", entry->name ) ) { free( new_filename ); return; } } copy_file (entry->fullfilename, new_filename); free( new_filename ); if( backs_list->mini_extension != NULL && entry->preview != NULL ) { char *mini_filename, *mini_fullfilename ; Bool do_mini = True ; asgtk_image_dir_make_mini_names( backs_list, entry->name, &mini_filename, &mini_fullfilename ); if( CheckFile( mini_fullfilename ) == 0 ) { if( !asgtk_yes_no_question1( WallpaperState.main_window, "Overwrite minipixmap \"%s\" with the new one ?", mini_filename ) ) do_mini = False ; } if( do_mini ) make_mini_for_image_entry( id, entry, mini_fullfilename); free( mini_fullfilename ); free( mini_filename ); } asgtk_info2( WallpaperState.main_window, "New background \"%s\" added.", entry->name, NULL ); unref_asimage_list_entry( entry ); asgtk_image_dir_refresh( backs_list ); } }
void on_edit_xml_clicked(GtkButton *button, gpointer user_data) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); ASImageListEntry *entry = asgtk_image_dir_get_selection( id ); if( WallpaperState.xml_editor == NULL ) { WallpaperState.xml_editor = asgtk_xml_editor_new(); g_signal_connect (G_OBJECT (WallpaperState.xml_editor), "destroy", G_CALLBACK (gtk_xml_editor_destroy), NULL); asgtk_xml_editor_file_change_handler( ASGTK_XML_EDITOR(WallpaperState.xml_editor), on_backgrounds_dir_changed, (gpointer)WallpaperState.backs_list ); } gtk_widget_show( WallpaperState.xml_editor ); asgtk_xml_editor_set_entry( ASGTK_XML_EDITOR(WallpaperState.xml_editor), entry ); unref_asimage_list_entry( entry ); gtk_widget_set_sensitive( GTK_WIDGET(WallpaperState.edit_xml_button), FALSE ); }
void on_make_mini_clicked(GtkButton *clicked_button, gpointer user_data) { ASGtkImageDir *id = ASGTK_IMAGE_DIR(user_data); ASImageListEntry *entry = asgtk_image_dir_get_selection( id ); char *mini_fullfilename = NULL ; if( asgtk_image_dir_make_mini_names( id, entry->name, NULL, &mini_fullfilename ) ) { if( make_mini_for_image_entry(id, entry, mini_fullfilename) ) { gtk_button_set_label(GTK_BUTTON(WallpaperState.make_mini_button), "Update mini"); asgtk_info2( WallpaperState.main_window, "Minipixmap successfully updated for background \"%s\".", entry->name, NULL ); }else asgtk_warning2( WallpaperState.main_window, "Failed to updated minipixmap for background \"%s\".", entry->name, NULL ); free( mini_fullfilename ); } unref_asimage_list_entry( entry ); }
void asgtk_image_view_set_entry (ASGtkImageView * iv, ASImageListEntry * image_entry) { g_return_if_fail (ASGTK_IS_IMAGE_VIEW (iv)); LOCAL_DEBUG_OUT (" ASGtk image view object's %p entry to %p", iv, image_entry); unref_asimage_list_entry (iv->image_entry); iv->image_entry = ref_asimage_list_entry (image_entry); if (iv->image_entry) { #if 1 asgtk_image_view_refresh (iv, (iv->image_entry->preview == NULL)); #endif } else { gtk_label_set_text (GTK_LABEL (iv->details_label), NO_IMAGE_TEXT); gtk_image_set_from_stock (GTK_IMAGE (iv->view), GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON); } }
static void refresh_gradient_preview(ASGtkGradient *ge) { int width = get_screen_width(NULL); int height = get_screen_height(NULL); struct ASGradient gradient ; struct ASImageListEntry *entry; ARGB32 *color ; double *offset ; if( ge->points->count <= 0 ) return ; if( GTK_WIDGET_STATE( ge->width_entry) != GTK_STATE_INSENSITIVE ) if( (width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->width_entry))) == 0 ) width = get_screen_width(NULL) ; if( GTK_WIDGET_STATE( ge->height_entry) != GTK_STATE_INSENSITIVE ) if( (height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->height_entry))) == 0 ) height = get_screen_height(NULL) ; entry = create_asimage_list_entry(); /* rendering gradient preview : */ gradient.npoints = 0 ; gradient.type = ge->type ; gradient.offset = offset = safemalloc((ge->points->count+2) * sizeof(double) ); gradient.color = color = safemalloc((ge->points->count+2) * sizeof(ARGB32) ); ++gradient.offset ; ++gradient.color ; iterate_asbidirlist( ge->points, add_point_to_gradient, &gradient, NULL, False ); if( gradient.offset[0] > 0. ) { --gradient.offset ; --gradient.color ; gradient.offset[0] = 0. ; gradient.color[0] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } if( gradient.offset[gradient.npoints-1] < 1. ) { gradient.offset[gradient.npoints] = 1. ; gradient.color[gradient.npoints] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } entry->preview = make_gradient(get_screen_visual(NULL), &gradient, width, height, SCL_DO_ALL, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT); free( offset ); free( color ); /* applying gradient preview : */ if( entry->preview ) asgtk_image_view_set_entry ( ge->image_view, entry); else asgtk_image_view_set_entry ( ge->image_view, NULL); unref_asimage_list_entry( entry ); }