/** \brief Save state of module manager. * * This function saves the state of the module manager. Currently, this consists * of saving the list of open modules. If no modules are open, the function saves * a NULL-list, indication that the corresponding configuration key should be * removed. */ void mod_mgr_save_state () { guint num; guint i; GtkWidget *module; gchar *mods = NULL; gchar *buff; if (!nbook) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Attempt to save state but mod-mgr is NULL?"), __FUNCTION__); return; } num = g_slist_length (modules); if (num == 0) { sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: No modules need to save state."), __FUNCTION__); sat_cfg_set_str (SAT_CFG_STR_OPEN_MODULES, NULL); return; } for (i = 0; i < num; i++) { module = GTK_WIDGET (g_slist_nth_data (modules, i)); /* save state of the module */ mod_cfg_save (GTK_SAT_MODULE (module)->name, GTK_SAT_MODULE (module)->cfgdata); if (i == 0) { buff = g_strdup (GTK_SAT_MODULE (module)->name); } else { buff = g_strconcat (mods, ";", GTK_SAT_MODULE (module)->name, NULL); g_free (mods); } mods = g_strdup (buff); g_free (buff); sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Stored %s"), __FUNCTION__, GTK_SAT_MODULE (module)->name); } sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Saved states for %d modules."), __FUNCTION__, num); sat_cfg_set_str (SAT_CFG_STR_OPEN_MODULES, mods); g_free (mods); }
/** \brief Add a new module to mod-mgr. * \param module The GtkSatModule widget to add * \param dock Flag indicating whether module should be docked or not. * * This function registers a new module in the mod-mgr. If the dock flag is true * the module is added to the mod-mgr notebook, otherwise it will be up to the * caller to create a proper container. * */ gint mod_mgr_add_module (GtkWidget *module, gboolean dock) { gint retcode = 0; gint page; if (module) { /* add module to internal list */ modules = g_slist_append (modules, module); if (dock) { /* add module to notebook if state = DOCKED */ page = gtk_notebook_append_page (GTK_NOTEBOOK (nbook), module, gtk_label_new (GTK_SAT_MODULE (module)->name)); /* allow nmodule to be dragged to different position */ gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK(nbook), module, TRUE); gtk_notebook_set_current_page (GTK_NOTEBOOK (nbook), page); /* send message to logger */ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Added %s to module manger (page %d)."), __FUNCTION__, GTK_SAT_MODULE (module)->name, page); } else { /* send message to logger */ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Added %s to module manger (NOT DOCKED)."), __FUNCTION__, GTK_SAT_MODULE (module)->name); } retcode = 0; } else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Module %s seems to be NULL"), __FUNCTION__, GTK_SAT_MODULE (module)->name); retcode = 1; } /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } update_window_title (); return retcode; }
/** \brief Millisecond controller wrap * \param widget Pointer to the millisecond controller widget * \param data Pointer to the GtkSatmodule structure. * * This function is called when the muillisecond controller wraps around its * limits. The current second is incremented or decremented according to * the wrap direction, then the current time is updated. */ static void tmg_msec_wrap (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); gint msec, sec; (void) widget; /* avoid unused parameter compiler warning */ sec = gtk_spin_button_get_value (GTK_SPIN_BUTTON (mod->tmgSec)); msec = gtk_spin_button_get_value (GTK_SPIN_BUTTON (mod->tmgMsec)); if (msec == 0) { /* 999 -> 0 wrap: increment seconds */ if (sec == 59) { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgSec), 0); tmg_sec_wrap (mod->tmgSec, data); } else { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgSec), sec+1); } } else { /* 0 -> 999 wrap: decrement seconds */ if (sec == 0) { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgSec), 59); tmg_sec_wrap (mod->tmgSec, data); } else { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgSec), sec-1); } } /* Note that the time will be updated automatically since the _set_value(sec) will trigger the "value-changed" signal */ }
/** brief Reload satellites in all modules. */ void mod_mgr_reload_sats () { guint num; guint i; GtkSatModule *mod; if (!nbook) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Attempt to reload sats but mod-mgr is NULL?"), __FUNCTION__); return; } num = g_slist_length (modules); if (num == 0) { sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: No modules need to reload sats."), __FUNCTION__); return; } /* for each module in the GSList execute sat_module_reload_sats() */ for (i = 0; i < num; i++) { mod = GTK_SAT_MODULE (g_slist_nth_data (modules, i)); gtk_sat_module_reload_sats (mod); } }
/** \brief New satellite selected. * \param data Pointer to the GtkSatModule widget * * This menu item is activated when a new satellite is selected in the * "Select satellite" submenu of the module pop-up. This will trigger a call * to the select_sat() fuinction of the module, which in turn will call the * select_sat() function of each child view. * * The catalog number of the selected satellite is attached to the menu item */ static void sat_selected_cb (GtkWidget *menuitem, gpointer data) { gint catnum = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), "catnum")); GtkSatModule *module = GTK_SAT_MODULE(data); gtk_sat_module_select_sat(module, catnum); }
/** \brief Minute controller wrap * \param widget Pointer to the minute controller widget * \param data Pointer to the GtkSatModule structure. * * This function is called when the minute controller wraps around its * limits. The current hour is incremented or decremented according to * the wrap direction, then the current time is updated. */ static void tmg_min_wrap (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); gint hr, min; (void) widget; /* avoid unused parameter compiler warning */ hr = gtk_spin_button_get_value (GTK_SPIN_BUTTON (mod->tmgHour)); min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (mod->tmgMin)); if (min == 0) { /* 59 -> 0 wrap: increment hour */ if (hr == 23) { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgHour), 0); tmg_hour_wrap (mod->tmgHour, data); } else { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgHour), hr+1); } } else { /* 0 -> 59 wrap: decrement hour */ if (hr == 0) { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgHour), 23); tmg_hour_wrap (mod->tmgHour, data); } else { gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgHour), hr-1); } } /* Note that the time will be updated automatically since the _set_value(hour) will trigger the "value-changed" signal */ }
/** \brief Dock a module into the notebook. * \param module The module to insert into the notebook. * \return 0 if the operation was successful, 1 otherwise. * * This function inserts the module into the notebook but does not add it * to the list of modules, since it should already be there. * * The function does some sanity checks to ensure the the module actually * is in the internal list of modules and also that the module is not * already present in the notebook. If any of these checks fail, the function * will send an error message and try to recover. * * The function does not modify the internal state of the module, module->state, * that is up to the module itself. */ gint mod_mgr_dock_module (GtkWidget *module) { gint retcode = 0; gint page; if (!g_slist_find (modules, module)) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Module %s not found in list. Trying to recover."), __FUNCTION__, GTK_SAT_MODULE (module)->name); modules = g_slist_append (modules, module); } page = gtk_notebook_page_num (GTK_NOTEBOOK (nbook), module); if (page != -1) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Module %s already in notebook!"), __FUNCTION__, GTK_SAT_MODULE (module)->name); retcode = 1; } else { /* add module to notebook */ page = gtk_notebook_append_page (GTK_NOTEBOOK (nbook), module, gtk_label_new (GTK_SAT_MODULE (module)->name)); sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Docked %s into notebook (page %d)"), __FUNCTION__, GTK_SAT_MODULE (module)->name, page); retcode = 0; } /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } /* update window title */ update_window_title (); return retcode; }
/** \brief Open time manager. */ static void tmgr_cb (GtkWidget *menuitem, gpointer data) { GtkSatModule *module = GTK_SAT_MODULE (data); (void) menuitem; /* avoid unused parameter compiler warning */ tmg_create (module); }
/** \brief Undock module from notebook * \param module The module that should be undocked. * * This function removes module from the notebook without removing it from * the internal list of modules. * * The function does some sanity checks to ensure that the module actually * exists in the mod-mgr, if not it will add module to the internal list * and raise a warning. * * The function does not modify the internal state of the module, module->state, * that is up to the module itself. * * \note The module itself is responsible for temporarily incrementing the * reference count of the widget in order to avoid destruction when * removing from the notebook. */ gint mod_mgr_undock_module (GtkWidget *module) { gint retcode = 0; gint page; if (!g_slist_find (modules, module)) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Module %s not found in list. Trying to recover."), __FUNCTION__, GTK_SAT_MODULE (module)->name); modules = g_slist_append (modules, module); } page = gtk_notebook_page_num (GTK_NOTEBOOK (nbook), module); if (page == -1) { sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Module %s does not seem to be docked!"), __FUNCTION__, GTK_SAT_MODULE (module)->name); retcode = 1; } else { gtk_notebook_remove_page (GTK_NOTEBOOK (nbook), page); sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Removed %s from notebook page %d."), __FUNCTION__, GTK_SAT_MODULE (module)->name, page); retcode = 0; } /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } /* update window title */ update_window_title (); return retcode; }
/** \brief Destroy radio control window. * \param window Pointer to the radio control window. * \param data Pointer to the GtkSatModule to which this controller is attached. * * This function is called automatically when the window is destroyed. */ static void destroy_rigctrl (GtkWidget *window, gpointer data) { GtkSatModule *module = GTK_SAT_MODULE (data); (void) window; /* avoid unused parameter compiler warning */ module->rigctrlwin = NULL; module->rigctrl = NULL; }
/** \brief Invoke Sky-at-glance. * * This function is a shortcut to the sky at glance function * in that it will make the predictions with the satellites * tracked in the current module. */ static void sky_at_glance_cb (GtkWidget *menuitem, gpointer data) { GtkSatModule *module = GTK_SAT_MODULE (data); //GtkWidget *skg; //GtkWidget *window; gchar *buff; (void) menuitem; /* avoid unused parameter compiler warning */ /* if module is busy wait until done then go on */ g_mutex_lock(&module->busy); if (module->skgwin != NULL) { /* there is already a sky at glance for this module */ gtk_window_present (GTK_WINDOW (module->skgwin)); g_mutex_unlock(&module->busy); return; } /* create window */ module->skgwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); buff = g_strdup_printf (_("The sky at a glance (%s)"), module->name); gtk_window_set_title (GTK_WINDOW (module->skgwin), buff); g_free (buff); g_signal_connect (G_OBJECT (module->skgwin), "delete_event", G_CALLBACK (window_delete), NULL); g_signal_connect (G_OBJECT (module->skgwin), "destroy", G_CALLBACK (destroy_skg), module); /* window icon */ buff = icon_file_name ("gpredict-planner.png"); gtk_window_set_icon_from_file (GTK_WINDOW (module->skgwin), buff, NULL); g_free (buff); /* create sky at a glance widget */ if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { module->skg = gtk_sky_glance_new (module->satellites, module->qth, 0.0); } else { module->skg = gtk_sky_glance_new (module->satellites, module->qth, module->tmgCdnum); } /* store time at which GtkSkyGlance has been created */ module->lastSkgUpd = module->tmgCdnum; gtk_container_set_border_width (GTK_CONTAINER (module->skgwin), 10); gtk_container_add (GTK_CONTAINER (module->skgwin), module->skg); gtk_widget_show_all (module->skgwin); g_mutex_unlock(&module->busy); }
/** \brief Signal handler for slider "value-changed" signals * \param widget The widget that was modified. * \param data Pointer to the GtkSatModule structure. * * This function is called when the user moves the slider. * If we are in manual control mode, the function simpley calls * tmg_time_set(). In the other modes, the function switches over * to amnual mode first. */ static void slider_moved (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); if (mod->throttle) { /* "press" the stop button to trigger a transition into manual mode */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mod->tmgStop), TRUE); } tmg_time_set (widget, data); }
/** * \brief Manage STOP signals. * \param widget The GtkButton that received the signal. * \param data Pointer to the GtkSatModule widget. * * This function is called when the user clicks on the STOP button. * If the button state is active (pressed in) the function sets the * throttle parameter of the module to 0. */ static void tmg_stop(GtkWidget * widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE(data); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { sat_log_log(SAT_LOG_LEVEL_DEBUG, __func__); /* set throttle to 0 */ mod->throttle = 0; } }
/** \brief Open Radio control window. * \param menuitem The menuitem that was selected. * \param data Pointer the GtkSatModule. */ static void rigctrl_cb (GtkWidget *menuitem, gpointer data) { GtkSatModule *module = GTK_SAT_MODULE (data); gchar *buff; (void) menuitem; /* avoid unused parameter compiler warning */ if (module->rigctrlwin != NULL) { /* there is already a roto controller for this module */ gtk_window_present (GTK_WINDOW (module->rigctrlwin)); return; } module->rigctrl = gtk_rig_ctrl_new (module); if (module->rigctrl == NULL) { /* gtk_rot_ctrl_new returned NULL becasue no radios are configured */ GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (app), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("You have no radio configuration!\n"\ "Please configure a radio first.") ); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); gtk_window_set_title (GTK_WINDOW (dialog), _("ERROR")); gtk_widget_show_all (dialog); return; } /* create a window */ module->rigctrlwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); buff = g_strdup_printf (_("Gpredict Radio Control: %s"), module->name); gtk_window_set_title (GTK_WINDOW (module->rigctrlwin), buff); g_free (buff); g_signal_connect (G_OBJECT (module->rigctrlwin), "delete_event", G_CALLBACK (window_delete), NULL); g_signal_connect (G_OBJECT (module->rigctrlwin), "destroy", G_CALLBACK (destroy_rigctrl), module); /* window icon */ buff = icon_file_name ("gpredict-oscilloscope.png"); gtk_window_set_icon_from_file (GTK_WINDOW (module->rigctrlwin), buff, NULL); g_free (buff); gtk_container_add (GTK_CONTAINER (module->rigctrlwin), module->rigctrl); gtk_widget_show_all (module->rigctrlwin); }
/** \brief Remove a module from the notebook. * \param module The module that should be removed. * \return 0 if the module has been removed or 1 if the requested module * could not be found in the notebook. */ gint mod_mgr_remove_module (GtkWidget *module) { gint page; gint retcode = 0; /* remove from notebook */ if (GTK_SAT_MODULE (module)->state == GTK_SAT_MOD_STATE_DOCKED) { /* get page number for this module */ page = gtk_notebook_page_num (GTK_NOTEBOOK (nbook), module); if (page == -1) { /* this is some kind of bug (inconsistency between internal states) */ sat_log_log (SAT_LOG_LEVEL_BUG, _("%s: Could not find child in notebook. This may hurt..."), __FUNCTION__); retcode = 1; } else { gtk_notebook_remove_page (GTK_NOTEBOOK (nbook), page); sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Removed child from notebook page %d."), __FUNCTION__, page); retcode = 0; } } /* remove from list */ modules = g_slist_remove (modules, module); /* undocked modules will have to destroy themselves because of their parent window */ /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } /* update window title */ update_window_title (); return retcode; }
static void tmg_throttle (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); /* FFWD mode */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mod->tmgFwd))) { mod->throttle = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mod->tmgBwd))) { mod->throttle = -gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); } }
/** \brief Manage BWD signals. * \param widget The GtkButton that received the signal. * \param data Pointer to the GtkSatModule widget. * * This function is called when the user clicks on the BWD button. * If the button state is active (pressed in) the function sets the * throttle parameter of the module to -1. */ static void tmg_bwd (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { sat_log_log (SAT_LOG_LEVEL_DEBUG, __FUNCTION__); /* set throttle to -1 */ mod->throttle = -gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgFactor));; } }
/** \brief Close and permanently delete module. * * This function is called when the user selects the delete menu * item in the GtkSatModule popup menu. First it will close the module * with gtk_sat_module_close_cb, which will close the current module, * whereafter the module file will be deleted from the disk. */ static void delete_cb (GtkWidget *menuitem, gpointer data) { gchar *file; GtkWidget *dialog; gchar *moddir; moddir = get_modules_dir (); file = g_strconcat (moddir, G_DIR_SEPARATOR_S, GTK_SAT_MODULE (data)->name, ".mod", NULL); g_free (moddir); gtk_sat_module_close_cb (menuitem, data); /* ask user to confirm removal */ dialog = gtk_message_dialog_new_with_markup (NULL, //GTK_WINDOW (parent), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("This operation will permanently delete\n<b>%s</b>\n"\ "from the disk.\nDo you you want to proceed?"), file); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_YES: if (g_remove (file)) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to delete %s."), __FILE__, __LINE__, file); } else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: %s deleted permanently."), __FILE__, __LINE__, file); } break; default: break; } gtk_widget_destroy (dialog); g_free (file); }
static void tmg_destroy (GtkWidget *tmg, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); (void) tmg; /* avoid unused parameter compiler warning */ /* reset time keeping variables */ mod->throttle = 1; mod->tmgActive = FALSE; /* reset time */ tmg_reset (NULL, data); sat_log_log (SAT_LOG_LEVEL_INFO, _("%s: Time Controller for %s closed. Time reset."), __FUNCTION__, mod->name); }
/** \brief Hour controller wrap * \param widget Pointer to the hour controller widget * \param data Pointer to the GtkSatModule structure. * * This function is called when the hour controller wraps around its * limits. The current day is incremented or decremented according to * the wrap direction, then the current time is updated. */ static void tmg_hour_wrap (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); gint hour; (void) widget; /* avoid unused parameter compiler warning */ hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (mod->tmgHour)); if (hour == 0) { /* 23 -> 0 wrap: increment date */ tmg_cal_add_one_day (mod); } else { /* 0 -> 23 wrap: decrement data */ tmg_cal_sub_one_day (mod); } }
/** * \brief Set new date and time callback. * \param widget The widget that was modified. * \param data Pointer to the GtkSatModule structure. * * This function is called when the user changes the date or time in the time * controller. If we are in manual time control mode, the function reads the * date and time set in the control widget and calculates the new time for * the module. The function does nothing in real time and simulated real * time modes. */ static void tmg_time_set(GtkWidget * widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE(data); gdouble slider; gdouble jd; (void)widget; /* avoid unused parameter compiler warning */ /* update time only if we are in manual time control */ if (!mod->throttle && !mod->reset) { jd = calculate_time(mod); /* get slider offset */ slider = gtk_range_get_value(GTK_RANGE(mod->tmgSlider)); mod->tmgCdnum = jd + slider; } }
/** \brief Configure module. * * This function is called when the user selects the configure * menu item in the GtkSatModule popup menu. It is a simple * wrapper for gtk_sat_module_config_cb * */ static void config_cb (GtkWidget *menuitem, gpointer data) { GtkSatModule *module = GTK_SAT_MODULE (data); if (module->rigctrlwin || module->rotctrlwin) { GtkWidget *dialog; /* FIXME: should offer option to close controllers */ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("A module can not be configured while the "\ "radio or rotator controller is active.\n\n"\ "Please close the radio and rotator controllers "\ "and try again.")); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } else { gtk_sat_module_config_cb (menuitem, data); } }
/** \brief Manage Reset button clicks. * \param widget The button that received the "clicked" signal. * \param data Pointer to the GtkSatModule structure. * * This function is called when the user clicks on the Reset button. * It resets the current time by setting * * mod->tmgPdnum = mod->rtPrev; * mod->tmgCdnum = mod->rtNow; * */ static void tmg_reset (GtkWidget *widget, gpointer data) { GtkSatModule *mod = GTK_SAT_MODULE (data); (void) widget; /* avoid unused parameter compiler warning */ /* set reset flag in order to block widget signals */ mod->reset = TRUE; mod->tmgPdnum = mod->rtPrev; mod->tmgCdnum = mod->rtNow; /* RESET slider */ gtk_range_set_value (GTK_RANGE (mod->tmgSlider), 0.0); /* update widgets; widget signals will have no effect since the tmgReset flag is TRUE */ tmg_update_widgets (mod); /* clear reset flag */ mod->reset = FALSE; }
/** \brief Toggle dockig state. * * This function is called when the user selects the (Un)Dock menu * item in the GtkSatModule popup menu. If the current module state * is DOCKED, the module will be undocked and moved into it's own, * GtkWindow. If the current module state is WINDOW or FULLSCREEN, * the module will be docked. * * The text of the menu item will be changed corresponding to the * action that has been performed. */ static void docking_state_cb (GtkWidget *menuitem, gpointer data) { GtkWidget *module = GTK_WIDGET (data); GtkAllocation aloc; gint w,h; gchar *icon; /* icon file name */ gchar *title; /* window title */ (void) menuitem; /* avoid unused parameter compiler warning */ gtk_widget_get_allocation ( module, &aloc); switch (GTK_SAT_MODULE (module)->state) { case GTK_SAT_MOD_STATE_DOCKED: /* get stored size; use size from main window if size not explicitly stoed */ if (g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL)) { w = g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL); } else { w = aloc.width; } if (g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL)) { h = g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL); } else { h = aloc.height; } /* increase reference count of module */ g_object_ref (module); /* we don't need the positions */ //GTK_SAT_MODULE (module)->vpanedpos = -1; //GTK_SAT_MODULE (module)->hpanedpos = -1; /* undock from mod-mgr */ mod_mgr_undock_module (module); /* create window */ GTK_SAT_MODULE (module)->win = gtk_window_new (GTK_WINDOW_TOPLEVEL); title = g_strconcat (_("GPREDICT: "), GTK_SAT_MODULE (module)->name, " (", GTK_SAT_MODULE (module)->qth->name, ")", NULL); gtk_window_set_title (GTK_WINDOW (GTK_SAT_MODULE (module)->win), title); g_free (title); gtk_window_set_default_size (GTK_WINDOW (GTK_SAT_MODULE (module)->win), w, h); g_signal_connect (G_OBJECT (GTK_SAT_MODULE (module)->win), "configure_event", G_CALLBACK (module_window_config_cb), module); /* window icon */ icon = icon_file_name ("gpredict-icon.png"); if (g_file_test (icon, G_FILE_TEST_EXISTS)) { gtk_window_set_icon_from_file (GTK_WINDOW (GTK_SAT_MODULE (module)->win), icon, NULL); } g_free (icon); /* move window to stored position if requested by configuration */ if (sat_cfg_get_bool (SAT_CFG_BOOL_MOD_WIN_POS) && g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL) && g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)) { gtk_window_move (GTK_WINDOW (GTK_SAT_MODULE (module)->win), g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL), g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)); } /* add module to window */ gtk_container_add (GTK_CONTAINER (GTK_SAT_MODULE (module)->win), module); /* change internal state */ GTK_SAT_MODULE (module)->state = GTK_SAT_MOD_STATE_WINDOW; /* store new state in configuration */ g_key_file_set_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_STATE, GTK_SAT_MOD_STATE_WINDOW); /* decrease reference count of module */ g_object_unref (module); /* show window */ gtk_widget_show_all (GTK_SAT_MODULE (module)->win); /* reparent time manager window if visible */ if (GTK_SAT_MODULE (module)->tmgActive) { gtk_window_set_transient_for (GTK_WINDOW (GTK_SAT_MODULE (module)->tmgWin), GTK_WINDOW (GTK_SAT_MODULE (module)->win)); } break; case GTK_SAT_MOD_STATE_WINDOW: case GTK_SAT_MOD_STATE_FULLSCREEN: /* increase referene count */ g_object_ref (module); /* reparent time manager window if visible */ if (GTK_SAT_MODULE (module)->tmgActive) { gtk_window_set_transient_for (GTK_WINDOW (GTK_SAT_MODULE (module)->tmgWin), GTK_WINDOW (app)); } /* remove module from window, destroy window */ gtk_container_remove (GTK_CONTAINER (GTK_SAT_MODULE (module)->win), module); gtk_widget_destroy (GTK_SAT_MODULE (module)->win); GTK_SAT_MODULE (module)->win = NULL; /* dock into mod-mgr */ mod_mgr_dock_module (module); /* change internal state */ GTK_SAT_MODULE (module)->state = GTK_SAT_MOD_STATE_DOCKED; /* store new state in configuration */ g_key_file_set_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_STATE, GTK_SAT_MOD_STATE_DOCKED); /* decrease reference count of module */ g_object_unref (module); break; default: sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Unknown module state: %d"), __FILE__, __LINE__, GTK_SAT_MODULE (module)->state); break; } }
/** \brief Toggle screen state. * * This function is intended to toggle between FULLSCREEN * and WINDOW state. */ static void screen_state_cb (GtkWidget *menuitem, gpointer data) { GtkWidget *module = GTK_WIDGET (data); gint w,h; gchar *icon; /* icon file name */ gchar *title; /* window title */ (void) menuitem; /* avoid unused parameter compiler warning */ switch (GTK_SAT_MODULE (module)->state) { case GTK_SAT_MOD_STATE_DOCKED: /* increase reference count of module */ g_object_ref (module); /* undock from mod-mgr */ mod_mgr_undock_module (module); /* create window */ GTK_SAT_MODULE (module)->win = gtk_window_new (GTK_WINDOW_TOPLEVEL); title = g_strconcat (_("GPREDICT: "), GTK_SAT_MODULE (module)->name, " (", GTK_SAT_MODULE (module)->qth->name, ")", NULL); gtk_window_set_title (GTK_WINDOW (GTK_SAT_MODULE (module)->win), title); g_free (title); /* window icon */ icon = icon_file_name ("gpredict-icon.png"); if (g_file_test (icon, G_FILE_TEST_EXISTS)) { gtk_window_set_icon_from_file (GTK_WINDOW (GTK_SAT_MODULE (module)->win), icon, NULL); } g_free (icon); /* add module to window */ gtk_container_add (GTK_CONTAINER (GTK_SAT_MODULE (module)->win), module); /* change internal state */ GTK_SAT_MODULE (module)->state = GTK_SAT_MOD_STATE_FULLSCREEN; /* decrease reference count of module */ g_object_unref (module); gtk_window_fullscreen (GTK_WINDOW (GTK_SAT_MODULE (module)->win)); /* show window */ gtk_widget_show_all (GTK_SAT_MODULE (module)->win); /* reparent time manager window if visible */ if (GTK_SAT_MODULE (module)->tmgActive) { gtk_window_set_transient_for (GTK_WINDOW (GTK_SAT_MODULE (module)->tmgWin), GTK_WINDOW (GTK_SAT_MODULE (module)->win)); } break; case GTK_SAT_MOD_STATE_WINDOW: /* change internal state */ GTK_SAT_MODULE (module)->state = GTK_SAT_MOD_STATE_FULLSCREEN; gtk_window_fullscreen (GTK_WINDOW (GTK_SAT_MODULE (module)->win)); gtk_window_set_default_size (GTK_WINDOW (GTK_SAT_MODULE (module)->win), 800, 600); break; case GTK_SAT_MOD_STATE_FULLSCREEN: /* change internal state */ GTK_SAT_MODULE (module)->state = GTK_SAT_MOD_STATE_WINDOW; gtk_window_unfullscreen (GTK_WINDOW (GTK_SAT_MODULE (module)->win)); /* get stored size; use some standard size if not explicitly specified */ if (g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL)) { w = g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL); } else { w = 800; } if (g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL)) { h = g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL); } else { h = 600; } gtk_window_set_default_size (GTK_WINDOW (GTK_SAT_MODULE (module)->win), w, h); /* move window to stored position if requested by configuration */ if (sat_cfg_get_bool (SAT_CFG_BOOL_MOD_WIN_POS) && g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL) && g_key_file_has_key (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)) { gtk_window_move (GTK_WINDOW (GTK_SAT_MODULE (module)->win), g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL), g_key_file_get_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)); } /* store new state in configuration */ g_key_file_set_integer (GTK_SAT_MODULE (module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_STATE, GTK_SAT_MOD_STATE_WINDOW); break; default: sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Unknown module state: %d"), __FILE__, __LINE__, GTK_SAT_MODULE (module)->state); break; } }
static void menubar_open_mod_cb(GtkWidget * widget, gpointer data) { gchar *modnam = NULL; gchar *modfile; gchar *confdir; GtkWidget *module = NULL; (void)widget; (void)data; sat_log_log(SAT_LOG_LEVEL_DEBUG, _("%s: Open existing module..."), __func__); modnam = select_module(); if (modnam) { sat_log_log(SAT_LOG_LEVEL_DEBUG, _("%s: Open module %s."), __func__, modnam); confdir = get_modules_dir(); modfile = g_strconcat(confdir, G_DIR_SEPARATOR_S, modnam, ".mod", NULL); g_free(confdir); /* create new module */ module = gtk_sat_module_new(modfile); if (module == NULL) { /* mod manager could not create the module */ GtkWidget *dialog; dialog = gtk_message_dialog_new(GTK_WINDOW(app), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not open %s. " "Please examine the log " "messages for details."), modnam); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } else { /* if module state was window or user does not want to restore the state of the modules, pack the module into the notebook */ if ((GTK_SAT_MODULE(module)->state == GTK_SAT_MOD_STATE_DOCKED) || !sat_cfg_get_bool(SAT_CFG_BOOL_MOD_STATE)) { mod_mgr_add_module(module, TRUE); } else { mod_mgr_add_module(module, FALSE); create_module_window(module); } } g_free(modnam); g_free(modfile); } else { sat_log_log(SAT_LOG_LEVEL_DEBUG, _("%s: Open module cancelled."), __func__); } }
/* * Create a module window. * * This function is used to create a module window when opening modules * that should not be packed into the notebook. */ static void create_module_window(GtkWidget * module) { gint w, h; gchar *icon; /* icon file name */ gchar *title; /* window title */ GtkAllocation aloc; gtk_widget_get_allocation(module, &aloc); /* get stored size; use size from main window if size not explicitly stoed */ if (g_key_file_has_key(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL)) { w = g_key_file_get_integer(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_WIDTH, NULL); } else { w = aloc.width; } if (g_key_file_has_key(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL)) { h = g_key_file_get_integer(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_HEIGHT, NULL); } else { h = aloc.height; } /* create window */ GTK_SAT_MODULE(module)->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); title = g_strconcat(_("GPREDICT: "), GTK_SAT_MODULE(module)->name, " (", GTK_SAT_MODULE(module)->qth->name, ")", NULL); gtk_window_set_title(GTK_WINDOW(GTK_SAT_MODULE(module)->win), title); g_free(title); gtk_window_set_default_size(GTK_WINDOW(GTK_SAT_MODULE(module)->win), w, h); g_signal_connect(G_OBJECT(GTK_SAT_MODULE(module)->win), "configure_event", G_CALLBACK(module_window_config_cb), module); /* window icon */ icon = icon_file_name("gpredict-icon.png"); if (g_file_test(icon, G_FILE_TEST_EXISTS)) { gtk_window_set_icon_from_file(GTK_WINDOW(GTK_SAT_MODULE(module)->win), icon, NULL); } g_free(icon); /* move window to stored position if requested by configuration */ if (sat_cfg_get_bool(SAT_CFG_BOOL_MOD_WIN_POS) && g_key_file_has_key(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL) && g_key_file_has_key(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)) { gtk_window_move(GTK_WINDOW(GTK_SAT_MODULE(module)->win), g_key_file_get_integer(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_X, NULL), g_key_file_get_integer(GTK_SAT_MODULE(module)->cfgdata, MOD_CFG_GLOBAL_SECTION, MOD_CFG_WIN_POS_Y, NULL)); } /* add module to window */ gtk_container_add(GTK_CONTAINER(GTK_SAT_MODULE(module)->win), module); /* show window */ gtk_widget_show_all(GTK_SAT_MODULE(module)->win); /* reparent time manager window if visible */ if (GTK_SAT_MODULE(module)->tmgActive) { gtk_window_set_transient_for(GTK_WINDOW (GTK_SAT_MODULE(module)->tmgWin), GTK_WINDOW(GTK_SAT_MODULE(module)->win)); } }
/** \brief Create and initialise module manger. * \return The main module container widget (GtkNotebook). * * This function creates and initialises the module manager widget, which * consist of a GtkNotebook container. Before returning the container to the * caller, the function checks whether any modules should be restored (ie. * openend), if yes, it creates them and adds them to the notebook. * */ GtkWidget * mod_mgr_create (void) { gchar *openmods = NULL; gchar **mods; gint count,i; GtkWidget *module; gchar *modfile; gchar *confdir; /* create notebook */ nbook = gtk_notebook_new (); gtk_notebook_set_scrollable (GTK_NOTEBOOK (nbook), TRUE); gtk_notebook_popup_enable (GTK_NOTEBOOK (nbook)); g_object_set (G_OBJECT (nbook), "homogeneous", TRUE, NULL); g_signal_connect (G_OBJECT (nbook), "switch-page", G_CALLBACK (switch_page_cb), NULL); /* get list of modules which should be open */ openmods = sat_cfg_get_str (SAT_CFG_STR_OPEN_MODULES); if (openmods) { mods = g_strsplit (openmods, ";", 0); count = g_strv_length (mods); for (i = 0; i < count; i++) { /* get data file name */ confdir = get_modules_dir (); modfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, mods[i], ".mod", NULL); g_free (confdir); /* create module */ module = gtk_sat_module_new (modfile); if (IS_GTK_SAT_MODULE (module)) { /* if module state was window or user does not want to restore the state of the modules, pack the module into the notebook */ if ((GTK_SAT_MODULE (module)->state == GTK_SAT_MOD_STATE_DOCKED) || !sat_cfg_get_bool (SAT_CFG_BOOL_MOD_STATE)) { mod_mgr_add_module (module, TRUE); } else { mod_mgr_add_module (module, FALSE); create_module_window (module); } } else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to restore %s"), __FUNCTION__, mods[i]); } g_free (modfile); } g_strfreev (mods); g_free (openmods); /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } } else { sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: No modules have to be restored."), __FUNCTION__); } return nbook; }
/** \brief Clone module. * * This function is called when the user selects the clone * menu item in the GtkSatModule popup menu. the function creates * a dialog in which the user is asked for a new module name. * When a valid module name is available and the user clicks on OK, * an exact copy of the currwent module is created. * By default, the nes module will be opened but the user has the * possibility to override this in the dialog window. * */ static void clone_cb (GtkWidget *menuitem, gpointer data) { GtkWidget *dialog; GtkWidget *entry; GtkWidget *label; GtkWidget *toggle; GtkWidget *vbox; GtkAllocation aloc; guint response; GtkSatModule *module = GTK_SAT_MODULE (data); GtkSatModule *newmod; gchar *source,*target; gchar *icon; /* icon file name */ gchar *title; /* window title */ (void) menuitem; /* avoid unused parameter compiler warning */ dialog = gtk_dialog_new_with_buttons (_("Clone Module"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (module))), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); /* label */ label = gtk_label_new (_("Name of new module:")); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); /* name entry */ entry = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (entry), 25); gtk_entry_set_text (GTK_ENTRY (entry), module->name); gtk_widget_set_tooltip_text (entry, _("Enter a short name for this module.\n"\ "Allowed characters: 0..9, a..z, A..Z, - and _")); /*not sure what to do with the old private tip the new api does not like them _("The name will be used to identify the module " \ "and it is also used a file name for saving the data."\ "Max length is 25 characters.")); */ /* attach changed signal so that we can enable OK button when a proper name has been entered oh, btw. disable OK button to begin with.... */ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); g_signal_connect (entry, "changed", G_CALLBACK (name_changed), dialog); gtk_box_pack_start (GTK_BOX( vbox ), entry, FALSE, FALSE, 0); /* check button */ toggle = gtk_check_button_new_with_label (_("Open module when created")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE); gtk_widget_set_tooltip_text ( toggle, _("If checked, the new module will be opened "\ "after it has been created")); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 20); gtk_widget_show_all (vbox); /* run dialog */ response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { case GTK_RESPONSE_OK: sat_log_log (SAT_LOG_LEVEL_INFO, _("%s:%d: Cloning %s => %s"), __FILE__, __LINE__, module->name, gtk_entry_get_text (GTK_ENTRY (entry))); /* build full file names */ gchar *moddir = get_modules_dir (); source = g_strconcat (moddir, G_DIR_SEPARATOR_S, module->name, ".mod", NULL); target = g_strconcat (moddir, G_DIR_SEPARATOR_S, gtk_entry_get_text (GTK_ENTRY (entry)), ".mod", NULL); g_free (moddir); /* copy file */ if (gpredict_file_copy (source, target)) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to clone %s."), __FILE__, __LINE__, module->name); } else { sat_log_log (SAT_LOG_LEVEL_INFO, _("%s:%d: Successfully cloned %s."), __FILE__, __LINE__, module->name); /* open module if requested */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle))) { newmod = GTK_SAT_MODULE (gtk_sat_module_new (target)); newmod->state = module->state; if (newmod->state == GTK_SAT_MOD_STATE_DOCKED) { /* add to module manager */ mod_mgr_add_module (GTK_WIDGET (newmod), TRUE); } else { /* add to module manager */ mod_mgr_add_module (GTK_WIDGET (newmod), FALSE); /* create window */ newmod->win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (newmod->win), newmod->name); title = g_strconcat (_("GPREDICT: "), newmod->name, " (", newmod->qth->name, ")", NULL); gtk_window_set_title (GTK_WINDOW (newmod->win), title); g_free (title); /* use size of source module */ gtk_widget_get_allocation(GTK_WIDGET (module), &aloc); gtk_window_set_default_size (GTK_WINDOW (newmod->win), aloc.width, aloc.height); g_signal_connect (G_OBJECT (newmod->win), "configure_event", G_CALLBACK (module_window_config_cb), newmod); /* add module to window */ gtk_container_add (GTK_CONTAINER (newmod->win), GTK_WIDGET (newmod)); /* window icon */ icon = icon_file_name ("gpredict-icon.png"); if (g_file_test (icon, G_FILE_TEST_EXISTS)) { gtk_window_set_icon_from_file (GTK_WINDOW (newmod->win), icon, NULL); } g_free (icon); /* show window */ gtk_widget_show_all (newmod->win); } } } /* clean up */ g_free (source); g_free (target); break; case GTK_RESPONSE_CANCEL: sat_log_log (SAT_LOG_LEVEL_INFO, _("%s:%d: Cloning cancelled by user."), __FILE__, __LINE__); break; default: sat_log_log (SAT_LOG_LEVEL_INFO, _("%s:%d: Cloning interrupted."), __FILE__, __LINE__); break; } gtk_widget_destroy (dialog); }