~heepie202/realtimesunlightwallpaper/trunk

« back to all changes in this revision

Viewing changes to callbacks.c

  • Committer: Carles Sentis
  • Date: 2011-01-26 03:10:16 UTC
  • Revision ID: heepie202@gmail.com-20110126031016-u4vb4bwk4zssci7c
v0.4 - Wed26Jan

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        Window Buttons
98
98
*******************************************************/
99
99
void cmd_apply_clicked (GtkButton *button, ChData *data){
 
100
        data->var.apply_clicked = TRUE;
100
101
        change_wallpaper (data);
101
102
}
102
103
 
105
106
        gshort tmp_move_map;
106
107
        gchar *contents = g_malloc(1002);
107
108
        gchar *fname = g_strconcat(g_get_home_dir(), DIR_PROJECT, "/sunlight_options", NULL);
 
109
        data->var.apply_clicked = FALSE;
108
110
                
109
111
        gtk_widget_hide(data->main_window);
110
112
        
139
141
        gchar *file_time = g_strdup_printf("sunlight_wallpaper%ld.jpg", time(NULL));
140
142
        gchar *fname = g_strconcat(dir_project, "/get_image.sh", NULL);
141
143
        gchar *set_wallpaper = g_strdup_printf("%s %s/%s", GCONF_SET_WALLPAPER, dir_wallpapers, file_time);
142
 
        
143
144
        gshort gi_map_position = get_map_position(data);
144
145
        
145
 
        //g_print("gd_scale: %.2f, gi_map_position: %d\n\n", data->var.gd_map_scale, gi_map_position);
146
 
        
147
 
        if (data->var.gb_move_map == TRUE)
148
 
                move_earth(data);
 
146
        text1 = "#!/bin/bash\n\nCOUNTER=0\nwhile [  $COUNTER -lt 12 ]; do\n\tcurl ";
 
147
        text2 = g_strdup_printf(" > world.jpg\n\ttemp=$(stat -c%%s world.jpg)\n\tif [[ $temp > 1000 ]]\n\tthen rm -f %s/*.jpg\n\t\tmv world.jpg %s/%s\n\t\tcd %s", dir_wallpapers, dir_wallpapers, file_time, dir_wallpapers);
 
148
        text3 = g_strdup_printf("\n\t\tmogrify -crop 1600x710-158+30 %s", file_time);
 
149
        if(is_peters(data)){text4 = g_strdup_printf("\n\t\tcp %s sunlight_wallpaper_right.jpg\n\t\tcp %s sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1442x%d-%d+0 sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1442x%d+%d+0 sunlight_wallpaper_right.jpg\n\t\tmontage -geometry +0+0 sunlight_wallpaper_right.jpg sunlight_wallpaper_left.jpg %s", file_time, file_time, data->var.gi_map_height, gi_map_position, data->var.gi_map_height, 1442 - gi_map_position, file_time);}
 
150
        else{text4 = g_strdup_printf("\n\t\tcp %s sunlight_wallpaper_right.jpg\n\t\tcp %s sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1600x%d-%d+0 sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1600x%d+%d+0 sunlight_wallpaper_right.jpg\n\t\tmontage -geometry +0+0 sunlight_wallpaper_right.jpg sunlight_wallpaper_left.jpg %s", file_time, file_time, data->var.gi_map_height, gi_map_position, data->var.gi_map_height, 1600 - gi_map_position, file_time);}
 
151
        text5 = "\n\t\texit 0\n\tfi\n\tsleep 5\n\tlet COUNTER=COUNTER+1\ndone";
149
152
                
150
 
                text1 = "#!/bin/bash\n\nCOUNTER=0\nwhile [  $COUNTER -lt 12 ]; do\n\tcurl ";
151
 
                text2 = g_strdup_printf(" > world.jpg\n\ttemp=$(stat -c%%s world.jpg)\n\tif [[ $temp > 1000 ]]\n\tthen rm -f %s/*.jpg\n\t\tmv world.jpg %s/%s\n\t\tcd %s", dir_wallpapers, dir_wallpapers, file_time, dir_wallpapers);
152
 
                text3 = g_strdup_printf("\n\t\tmogrify -crop 1600x710-158+30 %s", file_time);
153
 
                if(is_peters(data)){text4 = g_strdup_printf("\n\t\tcp %s sunlight_wallpaper_right.jpg\n\t\tcp %s sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1442x%d-%d+0 sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1442x%d+%d+0 sunlight_wallpaper_right.jpg\n\t\tmontage -geometry +0+0 sunlight_wallpaper_right.jpg sunlight_wallpaper_left.jpg %s", file_time, file_time, data->var.gi_map_height, gi_map_position, data->var.gi_map_height, 1442 - gi_map_position, file_time);}
154
 
                else{text4 = g_strdup_printf("\n\t\tcp %s sunlight_wallpaper_right.jpg\n\t\tcp %s sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1600x%d-%d+0 sunlight_wallpaper_left.jpg\n\t\tmogrify -crop 1600x%d+%d+0 sunlight_wallpaper_right.jpg\n\t\tmontage -geometry +0+0 sunlight_wallpaper_right.jpg sunlight_wallpaper_left.jpg %s", file_time, file_time, data->var.gi_map_height, gi_map_position, data->var.gi_map_height, 1600 - gi_map_position, file_time);}
155
 
                text5 = "\n\t\texit 0\n\tfi\n\tsleep 5\n\tlet COUNTER=COUNTER+1\ndone";
156
 
        
157
 
        
158
153
        switch(data->var.gi_rd1){
159
154
                case 1: switch(data->var.gi_rd2){
160
155
                                        case 1: image_address = "http://static.die.net/earth/mercator/1600.jpg";
180
175
                         else contents = g_strconcat(text1, image_address, text2, text4, text5, NULL);
181
176
                 }
182
177
        }else contents = g_strconcat(text1, image_address, text2, text5, NULL);
183
 
                                        
 
178
                                
184
179
        if (g_file_set_contents(fname, contents, -1, NULL)) {
185
180
                if (g_chmod(fname, 0750) == 0) {
186
181
                        if (system(fname) == 0){