void module_buttons_handler (int x, int y, int mbutton) { int module; int row, col; /* Figure out which row and column the click came in */ row = (y / (SELECT_BUTTON_INTERVAL)); if ((y % SELECT_BUTTON_INTERVAL) <= 8) return; /* in the gap */ col = (x / (SELECT_BUTTON_INTERVAL)); if ((x % SELECT_BUTTON_INTERVAL) <= 8) return; module = row + (module_rows * col); select_module (module, mbutton); }
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__); } }