当前位置: 首页>>代码示例>>C++>>正文


C++ GTK_BUILDER函数代码示例

本文整理汇总了C++中GTK_BUILDER函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_BUILDER函数的具体用法?C++ GTK_BUILDER怎么用?C++ GTK_BUILDER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GTK_BUILDER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:30,代码来源:main.cpp

示例2: g_warning

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);
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:28,代码来源:Dialogs.cpp

示例3: reveal_one

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;
}
开发者ID:GNOME,项目名称:gtk,代码行数:26,代码来源:revealer.c

示例4: on_button_clicked_reset

/* 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), "");
}
开发者ID:rleigh-codelibre,项目名称:ogcalc,代码行数:29,代码来源:ogcalc.c

示例5: gjs_gtkbuilder_connect_signals

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;
}
开发者ID:tomnotcat,项目名称:gjs-gtkbuilder-1.33.14,代码行数:31,代码来源:gtkbuilder.c

示例6: update_settings_cb

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);
}
开发者ID:MM294,项目名称:gnome-control-center,代码行数:28,代码来源:gnome-region-panel-formats.c

示例7: dialog

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;
    }
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:27,代码来源:MainWindow.hpp

示例8: dialog

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;
    }
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:28,代码来源:MainWindow.hpp

示例9: seed_gtk_builder_connect_signals

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);
}
开发者ID:dannote,项目名称:seed,代码行数:31,代码来源:seed-gtkbuilder.c

示例10: cb_remove_url

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 ();
	}
}
开发者ID:City-busz,项目名称:mate-control-center,代码行数:33,代码来源:mate-network-properties.c

示例11: route_delete_clicked

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")));
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:35,代码来源:ip4-routes-dialog.c

示例12: tree_view_button_pressed_cb

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;
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:34,代码来源:ip4-routes-dialog.c

示例13: cell_editing_canceled

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")));
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:26,代码来源:ip4-routes-dialog.c

示例14: icon_captions_changed_callback

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);
}
开发者ID:Seb35,项目名称:nemo,代码行数:35,代码来源:nemo-file-management-properties.c

示例15: route_add_clicked

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")));
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:35,代码来源:ip4-routes-dialog.c


注:本文中的GTK_BUILDER函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。