int main(int argc, char ** argv) { /* Init GTK+ */ gtk_init( &argc, &argv ); builder = gtk_builder_new(); MainWindow* window = new MainWindow(GTK_BUILDER(builder)); gtk_builder_connect_signals( GTK_BUILDER(builder), window ); /* ============== CSS ============== */ GtkCssProvider *provider; GdkDisplay *display; GdkScreen *screen; provider = gtk_css_provider_new (); display = gdk_display_get_default (); screen = gdk_display_get_default_screen (display); gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_USER); gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider), "style.css", NULL); g_object_unref (provider); /* ============== /// ============== */ /* Start main loop */ gtk_main(); return 0; }
int main(int argc, char ** argv) { /* Init GTK+ */ gtk_init( &argc, &argv ); builder = gtk_builder_new(); MainWindow* window = new MainWindow(GTK_BUILDER(builder)); gtk_builder_connect_signals( GTK_BUILDER(builder), window ); /* Start main loop */ gtk_main(); return 0; }
PolygonDialog::PolygonDialog(GtkBuilder* builder, bool isFace){ GError* error = nullptr; // (char*) usado para tirar warnings do compilador char* ids[] = {(char*)"poly_list_store",(char*)"adj_x1",(char*)"adj_y1", (char*)"adj_z1",(char*)"dlog_add_poly",nullptr}; if(!gtk_builder_add_objects_from_file(builder, UI_FILE, ids, &error)){ g_warning( "%s", error->message ); g_free( error ); return; } m_dialog = GTK_WIDGET( gtk_builder_get_object( builder, "dlog_add_poly" ) ); m_entryName = GTK_WIDGET( gtk_builder_get_object( builder, "poly_name" ) ); m_entryX = GTK_WIDGET( gtk_builder_get_object( builder, "poly_x" ) ); m_entryY = GTK_WIDGET( gtk_builder_get_object( builder, "poly_y" ) ); m_entryZ = GTK_WIDGET( gtk_builder_get_object( builder, "poly_z" ) ); m_checkFilled = GTK_WIDGET( gtk_builder_get_object( builder, "poly_filled" ) ); GtkTreeView* tree = GTK_TREE_VIEW( gtk_builder_get_object( GTK_BUILDER(builder), "poly_treeview" ) ); m_model = gtk_tree_view_get_model(tree); // Agora com o 3D os poligonos não podem mais ser // preenchidos... gtk_widget_hide(m_checkFilled); gtk_builder_connect_signals(builder, this); }
static gboolean reveal_one (gpointer data) { GtkWidget *window = data; GtkBuilder *builder; gchar *name; GtkRevealer *revealer; builder = GTK_BUILDER (g_object_get_data (G_OBJECT (window), "builder")); name = g_strdup_printf ("revealer%d", count); revealer = (GtkRevealer *)gtk_builder_get_object (builder, name); gtk_revealer_set_reveal_child (revealer, TRUE); g_signal_connect (revealer, "notify::child-revealed", G_CALLBACK (change_direction), NULL); count++; if (count >= 9) { timeout = 0; return FALSE; } else return TRUE; }
/* This is a callback. This resets the values of the entry widgets, and clears the results. */ void on_button_clicked_reset( GtkWidget *widget, gpointer data ) { GtkWidget *pg_val; GtkWidget *ri_val; GtkWidget *cf_val; GtkWidget *og_result; GtkWidget *abv_result; GtkBuilder *builder; /* Find the Glade XML tree containing widget. */ builder = GTK_BUILDER(data); /* Pull the other widgets out the the tree. */ pg_val = GTK_WIDGET(gtk_builder_get_object(builder, "pg_entry")); ri_val = GTK_WIDGET(gtk_builder_get_object(builder, "ri_entry")); cf_val = GTK_WIDGET(gtk_builder_get_object(builder, "cf_entry")); og_result = GTK_WIDGET(gtk_builder_get_object(builder, "og_result")); abv_result = GTK_WIDGET(gtk_builder_get_object(builder, "abv_result")); gtk_spin_button_set_value (GTK_SPIN_BUTTON(pg_val), 0.0); gtk_spin_button_set_value (GTK_SPIN_BUTTON(ri_val), 0.0); gtk_spin_button_set_value (GTK_SPIN_BUTTON(cf_val), 0.0); gtk_label_set_text (GTK_LABEL(og_result), ""); gtk_label_set_text (GTK_LABEL(abv_result), ""); }
static JSBool gjs_gtkbuilder_connect_signals (JSContext *context, uintN argc, jsval *vp) { jsval *argv = JS_ARGV (context, vp); JSObject *obj = JS_THIS_OBJECT (context, vp); GtkBuilder *builder; builder_ud ud; builder = GTK_BUILDER (gjs_g_object_from_object (context, obj)); if (NULL == builder) { gjs_throw (context, "Gtk.Builder.connect_signals () invalid this"); return JS_FALSE; } if (argc < 1) { gjs_throw (context, "Gtk.Builder.connect_signals () takes arguments"); return JS_FALSE; } ud.ctx = context; ud.obj = JSVAL_TO_OBJECT (argv[0]); gtk_builder_connect_signals_full (builder, _gjs_builder_connect_func, &ud); JS_SET_RVAL(context, vp, JSVAL_VOID); return JS_TRUE; }
static void update_settings_cb (GtkTreeSelection *selection, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkTreeModel *model; GtkTreeIter iter; gchar *active_id; GtkWidget *treeview; GSettings *locale_settings; gchar *current_setting; if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { return; } gtk_tree_model_get (model, &iter, 0, &active_id, -1); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "region_selector")); locale_settings = g_object_get_data (G_OBJECT (treeview), "settings"); current_setting = g_settings_get_string (locale_settings, "region"); if (g_strcmp0 (active_id, current_setting) != 0) { g_settings_set_string (locale_settings, "region", active_id); } g_free (current_setting); g_free (active_id); }
void MainWindow::addLine(GtkBuilder* builder){ LineDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; c.emplace_back(dialog.getX1(), dialog.getY1()); c.emplace_back(dialog.getX2(), dialog.getY2()); Object* obj = _world->addLine( dialog.getName(), dialog.getColor(), c); _viewport->transformObj(obj); addObjOnListStore(dialog.getName(), "Line"); gtk_widget_queue_draw(_mainWindow); log("Nova reta adicionada.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::scaleSelectedObj(GtkBuilder* builder){ ScaleDialog dialog(GTK_BUILDER(builder)); bool finish = false; std::string name; GtkTreeIter iter; if(!getSelectedObjName(name, &iter)) return; while(!finish){ if(dialog.run() == 1){ try{ Object* obj = m_world->scaleObj(name, dialog.getSX(), dialog.getSY(), dialog.getSZ()); m_viewport->transformAndClipObj(obj); gtk_widget_queue_draw(m_mainWindow); log("Objeto escalonado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
SeedValue seed_gtk_builder_connect_signals(SeedContext ctx, SeedObject function, SeedObject this_object, gsize argument_count, const SeedValue arguments[], SeedException *exception) { builder_ud ud; GtkBuilder *b; CHECK_ARG_COUNT("GtkBuilder.connect_signals", 1); if (!seed_value_is_object (ctx, arguments[0])) { seed_make_exception (ctx, exception, "TypeError", "connect_signals expects one object as the first argument"); return seed_make_undefined (ctx); } b = GTK_BUILDER (seed_value_to_object (ctx, this_object, exception)); ud.ctx = ctx; ud.obj = arguments[0]; if (argument_count == 2) ud.user_data = arguments[1]; else ud.user_data = NULL; gtk_builder_connect_signals_full(b, seed_builder_connect_func, &ud); return seed_make_undefined (ctx); }
void MainWindow::addBSplineCurve(GtkBuilder* builder){ CurveDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; dialog.getCoords(c); Object* obj = m_world->addBSplineCurve(dialog.getName(), dialog.getColor(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), "Curve"); gtk_widget_queue_draw(m_mainWindow); log("Nova curva adicionada.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addSurface(GtkBuilder* builder){ SurfaceDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ auto& c = dialog.getCoords(); Object* obj = m_world->addSurface(dialog.getName(), dialog.getColor(), dialog.getSurfaceType(), dialog.getMaxLines(), dialog.getMaxCols(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), obj->getTypeName().c_str()); gtk_widget_queue_draw(m_mainWindow); log("Novo poligono adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addPoint(GtkBuilder* builder){ PointDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinate c(dialog.getX(),dialog.getY(),dialog.getZ()); Object* obj = m_world->addPoint( dialog.getName(), dialog.getColor(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), "Point"); gtk_widget_queue_draw(m_mainWindow); log("Novo ponto adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addPolygon(GtkBuilder* builder){ PolygonDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; dialog.getCoords(c); Object* obj = _world->addPolygon(dialog.getName(), dialog.getColor(), dialog.shouldBeFilled(), c); _viewport->transformObj(obj); addObjOnListStore(dialog.getName(), "Polygon"); gtk_widget_queue_draw(_mainWindow); log("Novo poligono adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
static void cb_remove_url (GtkButton *button, gpointer data) { GtkBuilder *builder = GTK_BUILDER (data); GtkTreeSelection *selection; GtkTreeIter iter; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (builder, "treeview_ignore_host"))); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gchar *url; GSList *pointer; gtk_tree_model_get (model, &iter, 0, &url, -1); pointer = ignore_hosts; while(pointer) { if(strcmp(url, (char *) pointer->data) == 0) { g_free (pointer->data); ignore_hosts = g_slist_delete_link(ignore_hosts, pointer); break; } pointer = g_slist_next(pointer); } g_free(url); populate_listmodel(GTK_LIST_STORE(model), ignore_hosts); save_ignore_hosts_to_gsettings (); } }
static void route_delete_clicked (GtkButton *button, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkTreeView *treeview; GtkTreeSelection *selection; GList *selected_rows; GtkTreeModel *model = NULL; GtkTreeIter iter; int num_rows; treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "ip4_routes")); selection = gtk_tree_view_get_selection (treeview); if (gtk_tree_selection_count_selected_rows (selection) != 1) return; selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); if (!selected_rows) return; if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data)) gtk_list_store_remove (GTK_LIST_STORE (model), &iter); g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_rows); num_rows = gtk_tree_model_iter_n_children (model, NULL); if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) { selection = gtk_tree_view_get_selection (treeview); gtk_tree_selection_select_iter (selection, &iter); } validate (GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes_dialog"))); }
void MainWindow::openFile(GtkBuilder* builder){ FileDialog dialog(GTK_BUILDER(builder)); if(dialog.run() == 1){ char* filename = dialog.getFileName(); if(filename == NULL) return; std::string file(filename); delete filename; try{ ObjReader r(file); for(auto obj : r.getObjs()){ try{ _world->addObj(obj); _viewport->transformObj(obj); addObjOnListStore(obj->getName(), obj->getTypeName().c_str()); }catch(MyException& e){ log(e.what()); } } log("Arquivo carregado.\n"); }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } } }
static gboolean tree_view_button_pressed_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); /* last_edited can be set e.g. when we get here by clicking an cell while * editing another cell. GTK3 issue neither editing-canceled nor editing-done * for cell renderer. Thus the previous cell value isn't saved. Store it now. */ if (last_edited && last_path) { GtkTreeIter iter; GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (widget))); GtkTreePath *last_treepath = gtk_tree_path_new_from_string (last_path); gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, last_treepath); gtk_list_store_set (store, &iter, last_column, last_edited, -1); gtk_tree_path_free (last_treepath); g_free (last_edited); last_edited = NULL; g_free (last_path); last_path = NULL; last_column = -1; } /* Ignore double clicks events. (They are issued after the single clicks, see GdkEventButton) */ if (event->type == GDK_2BUTTON_PRESS) return TRUE; gtk_widget_grab_focus (GTK_WIDGET (widget)); validate (GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes_dialog"))); return FALSE; }
void MainWindow::rotateSelectedObj(GtkBuilder* builder){ RotateDialog dialog(GTK_BUILDER(builder)); bool finish = false; std::string name; GtkTreeIter iter; if(!getSelectedObjName(name, &iter)) return; while(!finish){ if(dialog.run() == 1){ try{ Object* obj = _world->rotateObj(name, dialog.getAngulo(), Coordinate(dialog.getCX(), dialog.getCY()), dialog.getRotateType()); _viewport->transformObj(obj); gtk_widget_queue_draw(_mainWindow); log("Objeto rotacionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
static void cell_editing_canceled (GtkCellRenderer *renderer, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkTreeModel *model = NULL; GtkTreeSelection *selection; GtkTreeIter iter; guint32 column; if (last_edited) { selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (builder, "ip4_routes"))); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (renderer), "column")); gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, last_edited, -1); } g_free (last_edited); last_edited = NULL; } g_free (last_path); last_path = NULL; last_column = -1; validate (GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes_dialog"))); }
static void icon_captions_changed_callback (GtkComboBox *combo_box, gpointer user_data) { GPtrArray *captions; GtkBuilder *builder; int i; builder = GTK_BUILDER (user_data); captions = g_ptr_array_new (); for (i = 0; icon_captions_components[i] != NULL; i++) { GtkWidget *combo_box; int active; GPtrArray *column_names; char *name; combo_box = GTK_WIDGET (gtk_builder_get_object (builder, icon_captions_components[i])); active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); column_names = g_object_get_data (G_OBJECT (combo_box), "column_names"); name = g_ptr_array_index (column_names, active); g_ptr_array_add (captions, name); } g_ptr_array_add (captions, NULL); g_settings_set_strv (nemo_icon_view_preferences, NEMO_PREFERENCES_ICON_VIEW_CAPTIONS, (const char **)captions->pdata); g_ptr_array_free (captions, TRUE); }
static void route_add_clicked (GtkButton *button, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkWidget *widget; GtkListStore *store; GtkTreeIter iter; GtkTreeSelection *selection; GtkTreeViewColumn *column; GtkTreePath *path; GList *cells; widget = GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes")); store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (widget))); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_ADDRESS, "", -1); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); gtk_tree_selection_select_iter (selection, &iter); path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), COL_ADDRESS); /* FIXME: using cells->data is pretty fragile but GTK apparently doesn't * have a way to get a cell renderer from a column based on path or iter * or whatever. */ cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (widget), path, column, cells->data, TRUE); g_list_free (cells); gtk_tree_path_free (path); validate (GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes_dialog"))); }
static void xkb_layouts_drag_end (GtkWidget *widget, GdkDragContext *drag_context, gpointer user_data) { update_layouts_list (gtk_tree_view_get_model (GTK_TREE_VIEW (widget)), GTK_BUILDER (user_data)); }
static void show_layout_destroy (GtkWidget * dialog, gint group) { GtkBuilder *builder = GTK_BUILDER (g_object_get_data (G_OBJECT (dialog), "builderData")); g_object_unref (G_OBJECT (builder)); g_hash_table_remove (preview_dialogs, GINT_TO_POINTER (group)); }
void onButtonClicked(GtkWidget* widget, gpointer* data) { if (GTK_IS_BUILDER(data)) { GtkBuilder* builder = GTK_BUILDER(data); GtkWidget* window = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow")); if (exit_confirm(GTK_WIDGET(window))) { onDestoryed(widget, data); } } }
static void Calculate(GtkWidget *Widget, gpointer EvalWindow) { SilikoSyntaxTreeNode *ResultTree = SilikoParseInfix( SilikoStringSourceNew( gtk_entry_get_text( GTK_ENTRY( gtk_builder_get_object(GTK_BUILDER(EvalWindow), "Input"))))); SilikoValue Value = SilikoSyntaxTreeEvaluate(ResultTree); SilikoSyntaxTreeDelete(ResultTree); char *ResultString = SilikoValueToString(Value); gtk_label_set_text( GTK_LABEL( gtk_builder_get_object( GTK_BUILDER(EvalWindow), "Output")), ResultString); free(ResultString); }
static void cell_edited (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkWidget *widget, *dialog; GtkListStore *store; GtkTreePath *path; GtkTreeIter iter; guint32 column; GtkTreeViewColumn *next_col; GtkCellRenderer *next_cell; gboolean can_cycle; int direction, tmp; /* Free auxiliary stuff */ g_free (last_edited); last_edited = NULL; g_free (last_path); last_path = NULL; last_column = -1; widget = GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes")); store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (widget))); path = gtk_tree_path_new_from_string (path_string); column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "column")); gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path); gtk_list_store_set (store, &iter, column, new_text, -1); /* Move focus to the next/previous column */ can_cycle = g_object_get_data (G_OBJECT (cell), DO_NOT_CYCLE_TAG) == NULL; direction = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), DIRECTION_TAG)); g_object_set_data (G_OBJECT (cell), DIRECTION_TAG, NULL); g_object_set_data (G_OBJECT (cell), DO_NOT_CYCLE_TAG, NULL); if (direction == 0) /* Move forward by default */ direction = 1; tmp = column + direction; if (can_cycle) column = tmp < 0 ? COL_LAST : tmp > COL_LAST ? 0 : tmp; else column = tmp; next_col = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), column); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "ip4_routes_dialog")); next_cell = g_slist_nth_data (g_object_get_data (G_OBJECT (dialog), "renderers"), column); gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (widget), path, next_col, next_cell, TRUE); gtk_tree_path_free (path); validate (dialog); }
static void update_jobs_list_cb (cups_job_t *jobs, gint num_of_jobs, gpointer user_data) { PpJobsDialog *dialog = user_data; GtkWidget *clear_all_button; GtkStack *stack; guint i; g_list_store_remove_all (dialog->store); stack = GTK_STACK (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "stack")); clear_all_button = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "jobs-clear-all-button")); if (num_of_jobs > 0) { gtk_widget_set_sensitive (clear_all_button, TRUE); gtk_stack_set_visible_child_name (stack, "list-jobs-page"); } else { gtk_widget_set_sensitive (clear_all_button, FALSE); gtk_stack_set_visible_child_name (stack, "no-jobs-page"); } for (i = 0; i < num_of_jobs; i++) { PpJob *job; job = g_object_new (pp_job_get_type (), "id", jobs[i].id, "title", jobs[i].title, "state", jobs[i].state, NULL); g_list_store_append (dialog->store, job); } dialog->ref_count--; }
static void ccma_dialog_response_cb(GtkDialog * dialog, gint res, gpointer data) { // return ;// //GtkWidget*entry=GTK_ENTRY(data); CCManagerApplet *applet = CC_MANAGERAPPLET(data); GList *children = gtk_container_get_children(GTK_CONTAINER (gtk_dialog_get_content_area(dialog))); GtkWidget*box=children->data;//box GList*bc=gtk_container_get_children(GTK_CONTAINER(box)); GtkWidget*entry=GTK_WIDGET(g_list_next(bc)->data); /*FIXME get the correct entry widget */ // GtkWidget *entry = GTK_WIDGET(g_list_next(children)->data); // GtWidget* entry=get_child_widget_by_type(dialog,GTK_TYPE_ENTRY); // g_list_free(children); gboolean passok; switch (res) { case GTK_RESPONSE_OK: passok = check_passwd(gtk_entry_get_text(GTK_ENTRY(entry))); if (passok) { //OK GtkWidget*parent=GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(applet->loging_win->builder),"window")); applet->manager_panel=cc_mpanel_new(GTK_WINDOW(parent)); cc_mpanel_setup(applet->manager_panel); // // g_message("Authentication Successfilly!\n"); ccma_confirm_dialog_destroy(applet); } else { gtk_entry_set_text(GTK_ENTRY(entry), ""); } break; case GTK_RESPONSE_CANCEL: ccma_confirm_dialog_destroy(applet); break; default: break; } }
/* This callback does the actual calculation. */ void on_button_clicked_calculate( GtkWidget *widget, gpointer data ) { GtkWidget *pg_val; GtkWidget *ri_val; GtkWidget *cf_val; GtkWidget *og_result; GtkWidget *abv_result; gdouble pg, ri, cf, og, abv; gchar *og_string; gchar *abv_string; GtkBuilder *builder; /* Find the Glade XML tree containing widget. */ builder = GTK_BUILDER(data); /* Pull the other widgets out the the tree. */ pg_val = GTK_WIDGET(gtk_builder_get_object(builder, "pg_entry")); ri_val = GTK_WIDGET(gtk_builder_get_object(builder, "ri_entry")); cf_val = GTK_WIDGET(gtk_builder_get_object(builder, "cf_entry")); og_result = GTK_WIDGET(gtk_builder_get_object(builder, "og_result")); abv_result = GTK_WIDGET(gtk_builder_get_object(builder, "abv_result")); /* Get the numerical values from the entry widgets. */ pg = gtk_spin_button_get_value (GTK_SPIN_BUTTON(pg_val)); ri = gtk_spin_button_get_value (GTK_SPIN_BUTTON(ri_val)); cf = gtk_spin_button_get_value (GTK_SPIN_BUTTON(cf_val)); og = (ri * 2.597) - (pg * 1.644) - 34.4165 + cf; /* Do the sums. */ if (og < 60) abv = (og - pg) * 0.130; else abv = (og - pg) * 0.134; /* Display the results. Note the <b></b> GMarkup tags to make it display in Bold. */ og_string = g_strdup_printf ("<b>%0.2f</b>", og); abv_string = g_strdup_printf ("<b>%0.2f</b>", abv); gtk_label_set_markup (GTK_LABEL(og_result), og_string); gtk_label_set_markup (GTK_LABEL(abv_result), abv_string); g_free (og_string); g_free (abv_string); }