3
* Copyright (C) 2005 Kemal Ilgar Eroglu <kieroglu@math.washington.edu>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Library General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#define TIMEOUT_TIME 2000 /* Countdown update period in milliseconds */
22
#define PBAR_THICKNESS 10
25
#define WIDGET_SPACING 2
38
#include <libxfce4util/libxfce4util.h>
39
#include <libxfcegui4/xfce_iconbutton.h>
40
#include <libxfce4panel/xfce-panel-plugin.h>
41
#include <libxfcegui4/dialogs.h>
43
#include "xfcetimer.h"
45
static gboolean create_plugin_control (XfcePanelPlugin *plugin);
46
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(create_plugin_control);
48
void make_menu(plugin_data *pd);
51
* This is the timeout function that
54
static gboolean repeat_alarm (gpointer data){
56
plugin_data *pd=(plugin_data *)data;
58
/* Don't repeat anymore */
59
if(pd->rem_repetitions == 0){
61
if(pd->timeout_command)
62
g_free(pd->timeout_command);
63
pd->timeout_command=NULL;
64
pd->alarm_repeating=FALSE;
72
g_spawn_command_line_async (pd->timeout_command,NULL);
73
pd->rem_repetitions = pd->rem_repetitions -1 ;
79
* This is the timeout function that updates the
80
* tooltip, pbar and keeps track of elapsed time
82
static gboolean timeout_function (gpointer data){
84
plugin_data *pd=(plugin_data *)data;
85
gint elapsed_sec,remaining;
90
elapsed_sec=(gint)g_timer_elapsed(pd->timer,&zip);
92
/*g_fprintf(stderr,"\nElapsed %d seconds of %d",elapsed_sec,pd-
93
>timeout_period_in_sec);*/
95
/* If countdown is not over, update tooltip */
96
if(elapsed_sec < pd->timeout_period_in_sec){
98
remaining=pd->timeout_period_in_sec-elapsed_sec;
101
g_snprintf(tiptext,31,_("%dh %dm %ds left"),remaining/3600, (remaining%3600)/60,
103
else if (remaining>=60)
104
g_snprintf(tiptext,31,_("%dm %ds left"),remaining/60, remaining%60);
106
g_snprintf(tiptext,31,_("%ds left"),remaining);
108
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(pd->pbar),
109
((gdouble)elapsed_sec)/pd-> timeout_period_in_sec);
111
gtk_tooltips_set_tip(pd->tip,GTK_WIDGET(pd->base),tiptext,NULL);
117
/* Countdown is over, stop timer and free resources */
119
/*g_fprintf(stderr,"\nTimer command is ==> %s...",pd->timeout_command);*/
121
if( (strlen(pd->timeout_command)==0) || !pd->nowin_if_alarm ) {
122
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),1);
123
dialog = gtk_message_dialog_new (NULL,
124
GTK_DIALOG_DESTROY_WITH_PARENT,
127
_("Beeep! :) \nTime is up!"));
129
g_signal_connect_swapped (dialog, "response",
130
G_CALLBACK (gtk_widget_destroy),
132
gtk_widget_show(dialog);
135
if(strlen(pd->timeout_command)>0) {
137
g_spawn_command_line_async (pd->timeout_command,NULL);
139
if(pd->repeat_alarm){
140
pd->alarm_repeating=TRUE;
141
pd->rem_repetitions=pd->repetitions;
142
if(pd->repeat_timeout!=0)
143
g_source_remove(pd->repeat_timeout);
144
pd->repeat_timeout = g_timeout_add(pd->repeat_interval*1000,repeat_alarm,pd);
148
if(pd->timeout_command)
149
g_free(pd->timeout_command);
150
pd->timeout_command=NULL;
155
g_timer_destroy(pd->timer);
157
gtk_tooltips_disable(pd->tip);
164
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),0);
168
/* This function won't be called again */
174
* This is the callback function called when a timer
175
* is selected in the popup menu
178
static void timer_selected (GtkWidget* menuitem, GdkEventButton* event, gpointer data){
180
plugin_data *pd=(plugin_data *)data;
185
/* Find the index of the menuitem selected, save it in pd->selected. Not very
187
while (GTK_MENU_ITEM(menuitem)!=g_array_index(pd->menuarray,GtkMenuItem*,row_count) )
190
pd->selected=row_count;
192
/*g_fprintf(stderr,"\n Selecten menuitem is %d",row_count);*/
197
* This is the callback function called when the
198
* start/stop item is selected in the popup menu
201
static void start_stop_selected (GtkWidget* menuitem, GdkEventButton* event, gpointer
204
plugin_data *pd=(plugin_data *)data;
208
gchar *timerinfo,*tout_command;
210
gint row_count,cur_h,cur_m,cur_s,time;
216
/* If counting down, we stop the timer and free the resources */
219
/*g_fprintf(stderr,"\nTimer is running, shutting down...");*/
221
g_timer_destroy(pd->timer);
223
g_source_remove(pd->timeout);
224
if(pd->timeout_command)
225
g_free(pd->timeout_command);
228
pd->timeout_command=NULL;
232
/* Disable tooltips, reset pbar */
233
gtk_tooltips_disable(pd->tip);
234
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),0);
243
/* If we're here then the timer is off, so we start it */
245
/*g_fprintf(stderr,"\nStarting timer...");*/
247
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(pd->list), &iter);
250
/* Empty timer list-> Nothing to do. pd->selected=0, though. */
254
/* Search the list item with the right index */
255
while (valid && row_count!=pd->selected){
256
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(pd->list), &iter);
260
gtk_tree_model_get (GTK_TREE_MODEL(pd->list), &iter, 2, &timerinfo, 3,
261
&tout_command, 4, &is_cd ,5, &time, -1);
263
/* This will not be freed until the timeout is destroyed */
264
pd->timeout_command=tout_command;
266
/* If it's a 24h type alarm, we find the difference with current time
267
Here 'time' is in minutes */
270
g_get_current_time(&timeval);
271
current = localtime((time_t *)&timeval.tv_sec);
272
strftime(temp,7,"%H",current);
274
/*g_fprintf(stderr,"\n Current time: %d : ",cur_h);*/
275
strftime(temp,7,"%M",current);
277
/*g_fprintf(stderr,"%d : ",cur_m);*/
278
strftime(temp,7,"%S",current);
280
/*g_fprintf(stderr,"%d \n",cur_s);*/
282
timeout_period=time*60 - ((60*cur_h + cur_m)*60 + cur_s);
284
if(timeout_period <0)
285
timeout_period+= 24*60*60;
288
/* Else 'time' already gives the countdown period in seconds */
292
pd->timeout_period_in_sec=timeout_period;
294
/* start the timer */
295
pd->timer=g_timer_new();
301
gtk_tooltips_set_tip(pd->tip, GTK_WIDGET(pd->base), timerinfo, NULL);
302
gtk_tooltips_enable(pd->tip);
305
g_timer_start(pd->timer);
306
pd->timeout = g_timeout_add(TIMEOUT_TIME, timeout_function,pd);
313
* Callback when "Stop the alarm" is selected in the popup menu
316
static void stop_repeating_alarm (GtkWidget* menuitem, GdkEventButton* event, gpointer
318
plugin_data *pd=(plugin_data *)data;
320
g_source_remove(pd->repeat_timeout);
322
pd->alarm_repeating=FALSE;
324
if(pd->timeout_command){
325
g_free(pd->timeout_command);
326
pd->timeout_command=NULL;
334
* Callback when clicking on pbar. Pops the menu up/down
336
static void pbar_clicked (GtkWidget *pbar, GdkEventButton *event, gpointer data){
338
plugin_data *pd=(plugin_data *)data;
340
/*g_fprintf(stderr,"\nReceived click on button %d",event->button);*/
344
g_fprintf(stderr,"\nNo menu\n");
349
gtk_menu_popup (GTK_MENU(pd->menu),NULL,NULL,NULL,NULL,event->button,event->time);
351
gtk_menu_popdown(GTK_MENU(pd->menu));
356
* This function generates the popup menu
358
void make_menu(plugin_data *pd){
364
gchar *timername,*timerinfo;
369
/* Destroy the existing one */
371
gtk_widget_destroy(pd->menu);
374
g_array_free(pd->menuarray,TRUE);
376
pd->menu=gtk_menu_new();
377
pd->menuarray=g_array_new(FALSE,TRUE,sizeof(menuitem));
380
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(pd->list), &iter);
385
/* Run through the list, read name and timer period info */
387
/*g_fprintf(stderr,"\nMaking menuitem %d while selected is %d",row_count,pd->
389
gtk_tree_model_get(GTK_TREE_MODEL(pd->list),&iter,1,&timername,2,&timerinfo,-1);
390
g_snprintf(itemtext,255,"%s (%s)",timername,timerinfo);
391
menuitem=gtk_radio_menu_item_new_with_label(group,itemtext);
392
gtk_widget_show(menuitem);
395
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
396
g_signal_connect (G_OBJECT(menuitem),"button_press_event",
397
G_CALLBACK(timer_selected),pd);
398
/* The selected timer is always active */
399
if(row_count==pd->selected)
400
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),TRUE);
401
/* others are disabled when timer or alarm is already running */
402
else if(pd->timer_on || pd->alarm_repeating)
403
gtk_widget_set_sensitive(GTK_WIDGET(menuitem),FALSE);
405
gtk_menu_shell_append(GTK_MENU_SHELL(pd->menu),menuitem);
407
/*g_fprintf(stderr,"\nAdding menuitem with label : %s",itemtext);*/
409
/* We add the address of menuitem to the array */
410
g_array_append_val(pd->menuarray,menuitem);
412
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(pd->list), &iter);
416
/* Horizontal line (empty item) */
417
menuitem=gtk_menu_item_new();
418
gtk_menu_shell_append(GTK_MENU_SHELL(pd->menu),menuitem);
419
gtk_widget_show(menuitem);
421
/* Start/stop menu item */
423
if(!pd->alarm_repeating){
425
menuitem=gtk_menu_item_new_with_label(_("Stop timer"));
427
menuitem=gtk_menu_item_new_with_label(_("Start timer"));
429
gtk_menu_shell_append (GTK_MENU_SHELL(pd->menu),menuitem);
430
g_signal_connect (G_OBJECT(menuitem),"button_press_event",
431
G_CALLBACK(start_stop_selected),pd);
432
gtk_widget_show(menuitem);
435
/* Stop repeating alarm if so */
436
if(pd->alarm_repeating) {
437
menuitem=gtk_menu_item_new_with_label(_("Stop the alarm"));
439
gtk_menu_shell_append (GTK_MENU_SHELL(pd->menu),menuitem);
440
g_signal_connect (G_OBJECT(menuitem),"button_press_event",
441
G_CALLBACK(stop_repeating_alarm),pd);
442
gtk_widget_show(menuitem);
444
gtk_widget_show(pd->menu);
451
* Callback to the OK button in the Add window
453
static void ok_add(GtkButton *button, gpointer data){
455
alarm_data *adata = (alarm_data *)data;
460
/* Add item to the list */
461
gtk_list_store_append(adata->pd->list,&iter);
463
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,
465
1,gtk_entry_get_text(GTK_ENTRY(adata->name)),
466
3,gtk_entry_get_text(GTK_ENTRY(adata->command)),
467
4,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adata->
469
/* Item count goes up by one */
470
adata->pd->count=adata->pd->count+1;
472
/* If the h-m-s format was chosen, convert time to seconds,
473
save the choice into the list */
474
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adata->rb1))){
476
t1=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->timeh));
477
t2=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->timem));
478
t3=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->times));
481
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,5,t,-1);
483
g_snprintf(timeinfo,15,_("%dh %dm %ds"),t1,t2,t3);
485
g_snprintf(timeinfo,15,_("%dm %ds"),t2,t3);
487
g_snprintf(timeinfo,15,_("%ds"),t3);
489
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,2,timeinfo,-1);
491
else{ /* The 24h format. Save time in minutes */
493
t1=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->time_h));
494
t2=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->time_m));
496
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,5,t,-1);
497
g_snprintf(timeinfo,9,_("At %02d:%02d"),t1,t2);
498
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,2,timeinfo,-1);
503
make_menu(adata->pd);
506
gtk_widget_destroy(GTK_WIDGET(adata->window));
514
* Callback for cancelling Add and Edit. Just closes the window :).
516
static void cancel_add_edit(GtkButton *button, gpointer data){
518
alarm_data *adata=(alarm_data *)data;
520
gtk_widget_destroy(GTK_WIDGET(adata->window));
528
* Callback for OK button on Edit window. See ok_add for comments.
530
static void ok_edit(GtkButton *button, gpointer data){
532
alarm_data *adata = (alarm_data *)data;
537
GtkTreeSelection *select;
540
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (adata->pd->tree));
542
if (gtk_tree_selection_get_selected (select, &model, &iter))
544
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,
545
1,gtk_entry_get_text(GTK_ENTRY(adata->name)),
546
3,gtk_entry_get_text(GTK_ENTRY(adata->command)),
547
4,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adata->
549
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adata->rb1))){
551
t1=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->timeh));
552
t2=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->timem));
553
t3=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->times));
555
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,5,t,-1);
557
g_snprintf(timeinfo,15,_("%dh %dm %ds"),t1,t2,t3);
559
g_snprintf(timeinfo,15,_("%dm %ds"),t2,t3);
561
g_snprintf(timeinfo,15,_("%ds"),t3);
563
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,2,timeinfo,-1);
567
t1=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->time_h));
568
t2=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adata->time_m));
570
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,5,t,-1);
571
g_snprintf(timeinfo,9,_("At %02d:%02d"),t1,t2);
572
gtk_list_store_set(GTK_LIST_STORE(adata->pd->list),&iter,2,timeinfo,-1);
578
make_menu(adata->pd);
580
gtk_widget_destroy(GTK_WIDGET(adata->window));
586
* Callback when first radio button in dialog has been selected.
588
static void alarmdialog_countdown_toggled (GtkButton *button, gpointer data)
590
//plugin_data *pd = (plugin_data *)data;
591
alarm_data *adata = (alarm_data *) data;
594
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
595
gtk_widget_set_sensitive(GTK_WIDGET(adata->timeh), active);
596
gtk_widget_set_sensitive(GTK_WIDGET(adata->timem), active);
597
gtk_widget_set_sensitive(GTK_WIDGET(adata->times), active);
601
* Callback when second radio button in dialog has been selected.
603
static void alarmdialog_alarmtime_toggled (GtkButton *button, gpointer data)
605
alarm_data *adata = (alarm_data *) data;
608
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
609
gtk_widget_set_sensitive(GTK_WIDGET(adata->time_h), active);
610
gtk_widget_set_sensitive(GTK_WIDGET(adata->time_m), active);
614
* Callback to the Add button in options window.
615
* Creates the Add window.
617
static void add_edit_clicked (GtkButton *buttonn, gpointer data){
619
plugin_data *pd = (plugin_data *)data;
623
GtkEntry *name,*command;
624
GtkSpinButton *timeh,*timem,*times,*time_h,*time_m;
625
GtkRadioButton *rb1,*rb2;
626
GtkWidget *hbox,*vbox,*button;
627
alarm_data *adata=g_new(alarm_data,1);
628
gchar *nc; gboolean is_cd; gint time;
630
GtkTreeSelection *select;
633
window = (GtkWindow *)gtk_window_new(GTK_WINDOW_TOPLEVEL);
635
adata->window=window;
638
gtk_window_set_modal(GTK_WINDOW(window),TRUE);
640
vbox=gtk_vbox_new(FALSE, BORDER);
641
gtk_container_add(GTK_CONTAINER(window),vbox);
642
gtk_container_set_border_width(GTK_CONTAINER(window), BORDER);
645
hbox=gtk_hbox_new(FALSE, BORDER);
646
gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE, WIDGET_SPACING);
648
label = (GtkLabel *)gtk_label_new (_("Name:"));
649
name = (GtkEntry *) gtk_entry_new_with_max_length(1023);
652
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE,0);
653
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(name),TRUE,TRUE,0);
656
rb1=(GtkRadioButton *)gtk_radio_button_new_with_label(NULL,_("Enter the countdown time"));
657
g_signal_connect(G_OBJECT(rb1), "toggled", G_CALLBACK(alarmdialog_countdown_toggled), adata);
658
rb2=(GtkRadioButton *)gtk_radio_button_new_with_label(gtk_radio_button_get_group
659
(rb1),_("Enter the time of alarm (24h format)"));
660
g_signal_connect(G_OBJECT(rb2), "toggled", G_CALLBACK(alarmdialog_alarmtime_toggled), adata);
663
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(rb1),TRUE,TRUE,0);
665
hbox=gtk_hbox_new(FALSE,0);
666
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(hbox),TRUE,TRUE,0);
668
timeh = (GtkSpinButton *)gtk_spin_button_new_with_range(0,23,1);
669
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(timeh),FALSE,FALSE, WIDGET_SPACING);
671
label = (GtkLabel *)gtk_label_new (_("h "));
672
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE, WIDGET_SPACING);
673
timem = (GtkSpinButton *)gtk_spin_button_new_with_range(0,59,1);
674
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(timem),FALSE,FALSE,WIDGET_SPACING);
676
label = (GtkLabel *)gtk_label_new (_("m "));
677
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE,WIDGET_SPACING);
678
times = (GtkSpinButton *)gtk_spin_button_new_with_range(0,59,1);
679
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(times),FALSE,FALSE,WIDGET_SPACING);
681
label = (GtkLabel *)gtk_label_new (_("s "));
682
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE,WIDGET_SPACING);
684
label = (GtkLabel *)gtk_label_new (_("or"));
685
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(label),TRUE,TRUE,BORDER);
688
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(rb2),TRUE,TRUE,0);
690
hbox=gtk_hbox_new(FALSE,WIDGET_SPACING);
691
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(hbox),TRUE,TRUE,0);
693
time_h = (GtkSpinButton *)gtk_spin_button_new_with_range(0,23,1);
694
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(time_h),FALSE,FALSE,0);
695
adata->time_h=time_h;
696
label = (GtkLabel *)gtk_label_new (":");
697
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE,WIDGET_SPACING);
698
time_m = (GtkSpinButton *)gtk_spin_button_new_with_range(0,59,1);
699
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(time_m),FALSE,FALSE,WIDGET_SPACING);
700
adata->time_m=time_m;
704
hbox=gtk_hbox_new(FALSE, BORDER);
705
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(hbox),TRUE,TRUE,WIDGET_SPACING);
707
label = (GtkLabel *)gtk_label_new (_("Command to run:"));
708
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(label),FALSE,FALSE,WIDGET_SPACING);
709
command = (GtkEntry *)gtk_entry_new_with_max_length(1023);
710
adata->command=command;
711
gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(command),TRUE,TRUE,WIDGET_SPACING);
715
//hbox=gtk_hbox_new(TRUE,0);
716
hbox = gtk_hbutton_box_new();
717
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
718
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), BORDER);
719
gtk_box_pack_start(GTK_BOX(vbox),hbox,TRUE,TRUE,WIDGET_SPACING);
720
//gtk_container_set_border_width(GTK_CONTAINER(hbox), BORDER);
722
button=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
723
gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,0);
724
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(cancel_add_edit),adata);
726
button=gtk_button_new_from_stock(GTK_STOCK_OK);
727
gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,0);
728
if(GTK_WIDGET(buttonn)==pd->buttonadd)
729
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(ok_add),adata);
731
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(ok_edit),adata);
735
/* If this is the add window, we're done */
736
if(GTK_WIDGET(buttonn)==pd->buttonadd) {
737
gtk_window_set_title(window,_("Add new alarm"));
738
gtk_widget_show_all(GTK_WIDGET(window));
739
alarmdialog_alarmtime_toggled(GTK_BUTTON(rb2), adata);
743
/* Else fill the values in the boxes with the current choices */
744
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (pd->tree));
745
/*gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);*/
747
if (gtk_tree_selection_get_selected (select, &model, &iter)){
748
gtk_tree_model_get(model,&iter,1,&nc,-1);
749
gtk_entry_set_text(GTK_ENTRY(name),nc);
752
gtk_tree_model_get(model,&iter,3,&nc,-1);
753
gtk_entry_set_text(GTK_ENTRY(command),nc);
756
gtk_tree_model_get(model,&iter,4,&is_cd,-1);
757
gtk_tree_model_get(model,&iter,5,&time,-1);
761
gtk_spin_button_set_value(GTK_SPIN_BUTTON(timeh),time/3600);
762
gtk_spin_button_set_value(GTK_SPIN_BUTTON(timem),(time%3600)/60);
763
gtk_spin_button_set_value(GTK_SPIN_BUTTON(times),time%60);
764
alarmdialog_alarmtime_toggled(GTK_BUTTON(rb2), adata);
765
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb1),TRUE);
769
gtk_spin_button_set_value(GTK_SPIN_BUTTON(time_h),time/60);
770
gtk_spin_button_set_value(GTK_SPIN_BUTTON(time_m),time%60);
771
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb2),TRUE); // active by default
776
gtk_window_set_title(window,_("Edit alarm"));
777
gtk_widget_show_all(GTK_WIDGET(window));
783
* Calllback for the remove button in the options
785
static void remove_clicked(GtkButton *button, gpointer data){
787
plugin_data *pd = (plugin_data *)data;
789
GtkTreeIter iter,iter_remove;
790
GtkTreeSelection *select;
796
/* Get the selected row */
797
select=gtk_tree_view_get_selection(GTK_TREE_VIEW(pd->tree));
799
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(pd->list), &iter);
805
/* Re-index the other rows */
807
/* The selected one is removed, the corresponding menuitem array is also
809
if(gtk_tree_selection_iter_is_selected(select,&iter)){
810
/*g_fprintf(stderr,"\n Removing node %d ...\n", row_count);*/
811
iter_remove=iter; /* Mark to be deleted */
812
g_array_remove_index(pd->menuarray,row_count);
813
if(pd->selected==row_count) /* Update the index of the selected item */
814
pd->selected=0; /* If the selected is deleted, new selected one is the first
815
one. The first radiomenuitem gets activated anyway */
816
else if(pd->selected > row_count)
817
pd->selected=pd->selected-1; /* Those coming after are shifted one behind */
820
/* Save new index on the remaning ones */
821
gtk_list_store_set (pd->list, &iter, 0,row_count, -1);
825
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(pd->list), &iter);
829
/* Remove the marked one */
830
gtk_list_store_remove (pd->list, &iter_remove);
832
/* Update item count and menu */
841
* Adds the progressbar, taking into account the orientation.
842
* pd->pbar is not destroyed, just reparented (saves fraction setting code etc.).
844
static void add_pbar(XfcePanelPlugin *plugin, plugin_data *pd){
846
gtk_widget_hide(pd->eventbox);
848
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
850
/* Always true except at initialization */
852
g_object_ref(G_OBJECT(pd->pbar));
853
gtk_container_remove(GTK_CONTAINER(pd->box),pd->pbar);
854
gtk_widget_destroy(pd->box);
858
if(xfce_panel_plugin_get_orientation(plugin)==GTK_ORIENTATION_HORIZONTAL){
859
pd->box=gtk_hbox_new(TRUE,0);
860
gtk_container_add(GTK_CONTAINER(pd->eventbox),pd->box);
861
gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR(pd->
862
pbar),GTK_PROGRESS_BOTTOM_TO_TOP);
863
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),PBAR_THICKNESS,0);
864
gtk_box_pack_start(GTK_BOX(pd->box),gtk_vseparator_new(),FALSE,FALSE,0);
865
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);
866
gtk_box_pack_start(GTK_BOX(pd->box),gtk_vseparator_new(),FALSE,FALSE,0);
869
else{ /* horizontal bar */
870
pd->box=gtk_vbox_new(TRUE,0);
871
gtk_container_add(GTK_CONTAINER(pd->eventbox),pd->box);
872
gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR(pd->
873
pbar),GTK_PROGRESS_LEFT_TO_RIGHT);
874
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),0,PBAR_THICKNESS);
875
gtk_box_pack_start(GTK_BOX(pd->box),gtk_hseparator_new(),FALSE,FALSE,0);
876
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);
877
gtk_box_pack_start(GTK_BOX(pd->box),gtk_hseparator_new(),FALSE,FALSE,0);
881
gtk_widget_show_all(pd->eventbox);
885
* Callback for orientation change of panel. Just calls add_pbar.
887
static void orient_change(XfcePanelPlugin *plugin, GtkOrientation orient, plugin_data *pd){
893
* Loads the list from a keyfile, then saves them in a list_store
895
static void load_settings(plugin_data *pd)
899
const gchar *timerstring;
905
//if ((file=xfce_panel_plugin_lookup_rc_file (pd->base)) != NULL) {
908
if (g_file_test(pd->configfile,G_FILE_TEST_EXISTS)) {
910
rc = xfce_rc_simple_open (pd->configfile, TRUE);
918
g_sprintf(groupname,"G0");
921
while(xfce_rc_has_group(rc,groupname)){
923
xfce_rc_set_group(rc,groupname);
925
/*g_fprintf(stderr,"\nLoading item %d\n",groupnum);*/
926
gtk_list_store_append(pd->list,&iter);
928
timerstring=(gchar *)xfce_rc_read_entry(rc,"timername","No name");
929
gtk_list_store_set(pd->list,&iter,0,groupnum,1,timerstring,-1);
930
/* g_free(timerstring); */ /* Entries read are not freed ! */
932
timerstring=(gchar *)xfce_rc_read_entry(rc,"timercommand","");
933
gtk_list_store_set(pd->list,&iter,3,timerstring,-1);
934
/*g_fprintf(stderr,"\nLoaded timer command ==> %s... with length %d",
935
timerstring,strlen(timerstring));*/
936
/*g_free(timerstring);*/
938
timerstring=(gchar *)xfce_rc_read_entry(rc,"timerinfo","");
939
gtk_list_store_set(pd->list,&iter,2,timerstring,-1);
941
/*g_free(timerstring);*/
943
is_cd=xfce_rc_read_bool_entry(rc,"is_countdown",TRUE);
944
time=xfce_rc_read_int_entry(rc,"time",0);
946
gtk_list_store_set(pd->list,&iter,4,is_cd,5,time,-1);
949
g_snprintf(groupname,5,"G%d",groupnum);
951
} /* end of while loop */
956
/* Read other options */
957
if(xfce_rc_has_group(rc,"others")){
958
xfce_rc_set_group(rc,"others");
959
pd->nowin_if_alarm= xfce_rc_read_bool_entry
960
(rc,"nowin_if_alarm",FALSE);
961
pd->repeat_alarm= xfce_rc_read_bool_entry
962
(rc,"repeat_alarm",FALSE);
963
pd->repetitions= xfce_rc_read_int_entry
964
(rc,"repetitions",1);
965
pd->repeat_interval= xfce_rc_read_int_entry
966
(rc,"repeat_interval",10);
970
add_pbar(pd->base,pd);
982
* Saves the list to a keyfile, backup a permanent copy
984
static void save_settings(XfcePanelPlugin *plugin, plugin_data *pd){
986
gchar *timername,*timercommand,*timerinfo;
989
gchar settings[1024];
990
gchar settingsbak[1024];
1001
gchar *file, *contents=NULL;
1003
if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
1006
// We do this to start a fresh config file, otherwise if the old config file is longer,
1007
// the tail will not get truncated. See
1008
// http://bugzilla.xfce.org/show_bug.cgi?id=2647
1009
// for a related bug report.
1010
conffile = fopen(file,"w");
1014
rc = xfce_rc_simple_open (file, FALSE);
1021
/*g_fprintf(stderr,"\n Running write\n");*/
1023
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(pd->list), &iter);
1029
gtk_tree_model_get (GTK_TREE_MODEL(pd->list), &iter,
1036
g_snprintf(groupname,7,"G%d",row_count);
1037
xfce_rc_set_group(rc,groupname);
1039
xfce_rc_write_entry(rc,"timername",timername);
1041
xfce_rc_write_int_entry(rc,"time",time);
1043
xfce_rc_write_entry(rc,"timercommand",timercommand);
1045
xfce_rc_write_entry(rc,"timerinfo",timerinfo);
1047
xfce_rc_write_bool_entry(rc,"is_countdown",is_cd);
1050
g_free(timercommand);
1054
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(pd->list), &iter);
1058
/* save the other options */
1059
xfce_rc_set_group(rc,"others");
1061
xfce_rc_write_bool_entry(rc,"nowin_if_alarm",pd->nowin_if_alarm);
1062
xfce_rc_write_bool_entry(rc,"repeat_alarm",pd->repeat_alarm);
1063
xfce_rc_write_int_entry(rc,"repetitions",pd->repetitions);
1064
xfce_rc_write_int_entry(rc,"repeat_interval",pd->repeat_interval);
1068
conffile = fopen (pd->configfile,"w");
1069
/* We backup a permanent copy, which we'll use to load settings */
1070
if (conffile && g_file_get_contents(file,&contents,NULL,NULL)){
1071
fputs(contents,conffile);
1083
* Activates the Edit and Remove buttons when an item in the list is selected
1086
static void tree_selected (GtkTreeSelection *select, gpointer data){
1088
plugin_data *pd=(plugin_data *)data;
1090
gtk_widget_set_sensitive(pd->buttonedit,TRUE);
1091
gtk_widget_set_sensitive(pd->buttonremove,TRUE);
1096
/******************/
1098
/******************/
1101
plugin_free (XfcePanelPlugin *plugin, plugin_data *pd)
1105
g_return_if_fail(ctrl != NULL);
1106
g_return_if_fail(ctrl-> data != NULL);
1108
pd = (plugin_data*) ctrl->data;*/
1110
/* remove timeouts */
1111
if (pd->timeout!=0) g_source_remove(pd->timeout);
1112
if (pd->repeat_timeout!=0) g_source_remove(pd->repeat_timeout);
1114
/*save_settings(pd);*/
1117
g_timer_destroy(pd->timer);
1119
if(pd->timeout_command)
1120
g_free(pd->timeout_command);
1123
g_free(pd->configfile);
1125
gtk_object_destroy(GTK_OBJECT(pd->tip));
1128
g_array_free(pd->menuarray,TRUE);
1130
/* destroy all widgets */
1131
gtk_widget_destroy(GTK_WIDGET(pd->eventbox));
1133
/* destroy the tooltips */
1134
/*gtk_object_destroy(GTK_OBJECT(pd->tip));*/
1136
//if(G_IS_OBJECT(pd->list))
1137
// g_free(pd->list);
1139
// g_fprintf(stderr,"\npd->list is non-object");
1141
/* free the plugin data structure */
1147
/***************************/
1148
/* options dialog response */
1149
/***************************/
1151
options_dialog_response (GtkWidget *dlg, int reponse, plugin_data *pd)
1153
gtk_widget_destroy (dlg);
1154
xfce_panel_plugin_unblock_menu (pd->base);
1155
save_settings(pd->base,pd);
1158
/********************************/
1159
/* nowin_if_alarm toggle callback */
1160
/********************************/
1161
static void toggle_nowin_if_alarm(GtkToggleButton *button, gpointer data){
1163
plugin_data *pd=(plugin_data *)data;
1165
pd->nowin_if_alarm = gtk_toggle_button_get_active(button);
1169
/***************************************/
1170
/* toggle_repeat_alarm toggle callback */
1171
/***************************************/
1172
static void toggle_repeat_alarm(GtkToggleButton *button, gpointer data){
1174
plugin_data *pd=(plugin_data *)data;
1176
pd->repeat_alarm = gtk_toggle_button_get_active(button);
1177
gtk_widget_set_sensitive(GTK_WIDGET(pd->spin_interval), pd->repeat_alarm);
1178
gtk_widget_set_sensitive(GTK_WIDGET(pd->spin_repeat), pd->repeat_alarm);
1180
gtk_widget_set_sensitive(pd->repeat_alarm_box,pd->repeat_alarm);
1184
/***************************************/
1185
/* Spinbutton 1 (#of alarm repetitions */
1186
/* value change callback */
1187
/***************************************/
1188
static void spin1_changed(GtkSpinButton *button, gpointer data){
1190
plugin_data *pd=(plugin_data *)data;
1192
pd->repetitions = gtk_spin_button_get_value_as_int(button);
1196
/***************************************/
1197
/* Spinbutton 1 (alarm repetition */
1198
/* interval) value change callback */
1199
/***************************************/
1200
static void spin2_changed(GtkSpinButton *button, gpointer data){
1202
plugin_data *pd=(plugin_data *)data;
1204
pd->repeat_interval = gtk_spin_button_get_value_as_int(button);
1208
/******************/
1209
/* options dialog */
1210
/******************/
1211
static void plugin_create_options (XfcePanelPlugin *plugin,plugin_data *pd) {
1213
GtkWidget *vbox=gtk_vbox_new(FALSE,0); /*outermost box */
1214
GtkWidget *hbox=gtk_hbox_new(FALSE,0); /* holds the treeview and buttons */
1215
GtkWidget *buttonbox,*button,*sw,*tree,*spinbutton;
1216
GtkTreeSelection *select;
1217
GtkCellRenderer *renderer;
1218
GtkTreeViewColumn *column;
1221
GtkWidget *dlg, *header;
1224
xfce_panel_plugin_block_menu (plugin);
1226
dlg = gtk_dialog_new_with_buttons (_("Xfce 4 Timer Plugin"),
1227
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
1228
GTK_DIALOG_DESTROY_WITH_PARENT |
1229
GTK_DIALOG_NO_SEPARATOR,
1230
GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
1233
g_signal_connect (dlg, "response", G_CALLBACK (options_dialog_response),
1236
gtk_container_set_border_width (GTK_CONTAINER(dlg), BORDER);
1238
header = xfce_create_header (NULL, _("Xfce4 Timer Options"));
1239
gtk_widget_set_size_request (GTK_BIN (header)->child, 200, 32);
1240
//gtk_container_set_border_width (GTK_CONTAINER (header), 6);
1241
gtk_widget_show (header);
1242
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header,
1245
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox,
1246
TRUE, TRUE, WIDGET_SPACING);
1249
hbox = gtk_hbox_new(FALSE, BORDER);
1250
gtk_box_pack_start(GTK_BOX(vbox),hbox,TRUE,TRUE,BORDER);
1252
sw = gtk_scrolled_window_new (NULL, NULL);
1254
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1255
GTK_SHADOW_ETCHED_IN);
1256
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1257
GTK_POLICY_AUTOMATIC,
1258
GTK_POLICY_AUTOMATIC);
1260
gtk_box_pack_start(GTK_BOX(hbox),sw,TRUE,TRUE,0);
1262
tree=gtk_tree_view_new_with_model(GTK_TREE_MODEL(pd->list));
1264
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree), TRUE);
1265
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)),
1266
GTK_SELECTION_SINGLE);
1268
renderer = gtk_cell_renderer_text_new ();
1270
column = gtk_tree_view_column_new_with_attributes (_("Timer name"), renderer,
1272
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1275
column = gtk_tree_view_column_new_with_attributes (_("Countdown period /\nAlarm time"),
1276
renderer, "text", 2, NULL);
1277
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1279
column = gtk_tree_view_column_new_with_attributes (_("Alarm command"), renderer,
1281
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1285
gtk_container_add(GTK_CONTAINER(sw),tree);
1287
g_fprintf(stderr,"\n pd->tree is NULL\n");
1289
gtk_widget_set_size_request(GTK_WIDGET(sw),350,250);
1291
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (pd->tree));
1292
gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
1293
g_signal_connect (G_OBJECT (select), "changed",
1294
G_CALLBACK(tree_selected), pd);
1297
buttonbox=gtk_vbutton_box_new();
1298
gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox),GTK_BUTTONBOX_START);
1299
gtk_button_box_set_spacing(GTK_BUTTON_BOX(buttonbox),WIDGET_SPACING<<1);
1300
gtk_box_pack_start(GTK_BOX(hbox),buttonbox,FALSE,FALSE,0);
1302
button = gtk_button_new_from_stock (GTK_STOCK_ADD);
1303
pd->buttonadd=button;
1304
gtk_box_pack_start(GTK_BOX (buttonbox), button, FALSE, FALSE,WIDGET_SPACING<<1);
1305
gtk_widget_set_sensitive(button,TRUE);
1306
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(add_edit_clicked), pd);
1309
button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1310
pd->buttonedit=button;
1311
gtk_box_pack_start(GTK_BOX (buttonbox), button, FALSE, FALSE,WIDGET_SPACING<<1);
1312
gtk_widget_set_sensitive(button,FALSE);
1313
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(add_edit_clicked), pd);
1315
button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
1316
pd->buttonremove=button;
1317
gtk_box_pack_start(GTK_BOX (buttonbox), button, FALSE, FALSE,WIDGET_SPACING);
1318
gtk_widget_set_sensitive(button,FALSE);
1319
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(remove_clicked), pd);
1321
gtk_box_pack_start(GTK_BOX(vbox),gtk_hseparator_new(),FALSE,FALSE,BORDER);
1323
button=gtk_check_button_new_with_label(_("Don't display a warning if an alarm command is set"));
1324
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),pd->nowin_if_alarm);
1325
g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_nowin_if_alarm),pd);
1326
gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,WIDGET_SPACING);
1330
button=gtk_check_button_new_with_label(_("Repeat the alarm command:"));
1331
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),pd->repeat_alarm);
1332
g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_repeat_alarm),pd);
1333
gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,WIDGET_SPACING);
1335
hbox = gtk_hbox_new (FALSE,0);
1336
pd->repeat_alarm_box=hbox;
1337
gtk_box_pack_start(GTK_BOX(hbox),gtk_label_new(_("Number of repetitions")),FALSE,FALSE,0);
1338
spinbutton=gtk_spin_button_new_with_range(1,50,1);
1339
pd->spin_repeat=spinbutton;
1340
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), pd->repetitions);
1341
g_signal_connect(G_OBJECT(spinbutton),"value-changed", G_CALLBACK(spin1_changed), pd);
1342
gtk_box_pack_start(GTK_BOX(hbox),spinbutton,FALSE,FALSE,0);
1343
gtk_box_pack_start(GTK_BOX(hbox),gtk_label_new(_(" Time interval (sec.)")),FALSE,FALSE,0);
1344
spinbutton=gtk_spin_button_new_with_range(1,600,1);
1345
pd->spin_interval=spinbutton;
1346
gtk_box_pack_start(GTK_BOX(hbox),spinbutton,FALSE,FALSE,0);
1347
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), pd->repeat_interval);
1348
g_signal_connect(G_OBJECT(spinbutton),"value-changed", G_CALLBACK(spin2_changed), pd);
1350
gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,WIDGET_SPACING);
1351
gtk_widget_set_sensitive(hbox,pd->repeat_alarm);
1355
gtk_widget_show_all(GTK_WIDGET(dlg));
1361
* create_sample_control
1363
* Create a new instance of the plugin.
1365
* @control : #Control parent container
1367
* Returns %TRUE on success, %FALSE on failure.
1370
create_plugin_control (XfcePanelPlugin *plugin)
1373
GtkWidget *base,*menu,*socket,*menuitem,*box,*pbar2;
1374
GtkTooltips *tooltip;
1376
gchar *filename,*pathname;
1380
plugin_data *pd=g_new(plugin_data,1);
1384
pd->pbar=gtk_progress_bar_new();
1385
pd->list=gtk_list_store_new(6,
1386
G_TYPE_INT, /* Column 0: Index */
1387
G_TYPE_STRING, /* Column 1: Name */
1388
G_TYPE_STRING, /* Column 2: Timer period/alarm time */
1389
G_TYPE_STRING, /* Command to run */
1390
G_TYPE_BOOLEAN, /* TRUE= Is countdown, i.e. h-m-s format.
1391
FALSE= 24h format */
1392
G_TYPE_INT); /* Timer period in seconds if countdown.
1393
Alarm time in minutes if 24h format is used,
1394
(i.e. 60 x Hr + Min) */
1396
pd->eventbox=gtk_event_box_new();
1401
pd->buttonedit=NULL;
1402
pd->buttonremove=NULL;
1406
pd->tip=gtk_tooltips_new();
1407
pd->timeout_command=NULL;
1409
pd->nowin_if_alarm=FALSE;
1410
pd->repeat_alarm=FALSE;
1411
pd->repeat_alarm_box=NULL;
1413
pd->rem_repetitions=1;
1414
pd->repeat_interval=10;
1415
pd->alarm_repeating=FALSE;
1416
pd->repeat_timeout=0;
1418
gtk_tooltips_set_tip(pd->tip, GTK_WIDGET(plugin), "", NULL);
1419
gtk_tooltips_disable(pd->tip);
1422
g_object_ref(pd->list);
1424
filename = xfce_panel_plugin_save_location (pd->base,TRUE);
1425
pathname = g_path_get_dirname (filename);
1426
pd->configfile = g_strconcat (pathname,"/XfceTimer.rc",NULL);
1434
g_signal_connect (G_OBJECT(pd->eventbox), "button_press_event",
1435
G_CALLBACK(pbar_clicked), pd);
1437
gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR(pd->pbar),
1438
GTK_PROGRESS_CONTINUOUS);
1439
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),0);
1441
add_pbar(pd->base,pd);
1443
/* Trying to get a thin box, but no way */
1444
/*gtk_widget_set_size_request(pd->eventbox,0,0);*/
1445
gtk_widget_set_size_request(GTK_WIDGET(plugin),10,10);
1446
xfce_panel_plugin_set_expand(plugin,FALSE);
1448
gtk_container_add(GTK_CONTAINER(plugin),pd->eventbox);
1450
gtk_widget_show_all(GTK_WIDGET(plugin));
1452
g_signal_connect (plugin, "free-data",
1453
G_CALLBACK (plugin_free), pd);
1455
g_signal_connect (plugin, "save",
1456
G_CALLBACK (save_settings), pd);
1458
g_signal_connect (plugin, "orientation-changed",
1459
G_CALLBACK (orient_change), pd);
1461
xfce_panel_plugin_menu_show_configure (plugin);
1462
g_signal_connect (plugin, "configure-plugin",
1463
G_CALLBACK (plugin_create_options), pd);