コード例 #1
0
ファイル: popover.c プロジェクト: 3v1n0/gtk
static GtkWidget *
create_complex_popover (GtkWidget       *parent,
                        GtkPositionType  pos)
{
  GtkWidget *popover, *window, *content;
  GtkBuilder *builder;

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/popover/popover.ui", NULL);
  window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
  content = gtk_bin_get_child (GTK_BIN (window));
  g_object_ref (content);
  gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (content)),
                        content);
  gtk_widget_destroy (window);
  g_object_unref (builder);

  popover = create_popover (parent, content, GTK_POS_BOTTOM);
  g_object_unref (content);

  gtk_widget_set_size_request (popover, 200, -1);
  gtk_widget_set_vexpand (popover, TRUE);

  gtk_widget_set_margin_start (popover, 10);
  gtk_widget_set_margin_end (popover, 10);
  gtk_widget_set_margin_bottom (popover, 10);

  return popover;
}
コード例 #2
0
UmHistoryDialog *
um_history_dialog_new (void)
{
        GError *error = NULL;
        UmHistoryDialog *um;
        GtkWidget *widget;

        um = g_new0 (UmHistoryDialog, 1);
        um->builder = gtk_builder_new ();

        if (!gtk_builder_add_from_resource (um->builder, "/org/gnome/control-center/user-accounts/history-dialog.ui", &error)) {
                g_error ("%s", error->message);
                g_error_free (error);
                g_free (um);

                return NULL;
        }

        um->dialog = get_widget (um, "dialog");
        g_signal_connect (um->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);

        widget = get_widget (um, "close-button");
        g_signal_connect (widget, "clicked", G_CALLBACK (close_history_dialog), um);

        widget = get_widget (um, "next-button");
        g_signal_connect (widget, "clicked", G_CALLBACK (show_next), um);

        widget = get_widget (um, "previous-button");
        g_signal_connect (widget, "clicked", G_CALLBACK (show_previous), um);

        return um;
}
コード例 #3
0
static void 
display_properties_dialog (GtkAction *action,
			   PagerData *pager)
{
	if (pager->properties_dialog == NULL) {
		GtkBuilder *builder;

		builder = gtk_builder_new ();
		gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
		gtk_builder_add_from_resource (builder, WNCKLET_RESOURCE_PATH "workspace-switcher.ui", NULL);

		pager->properties_dialog = WID ("pager_properties_dialog");

		g_object_add_weak_pointer (G_OBJECT (pager->properties_dialog), 
					   (gpointer *) &pager->properties_dialog);

		setup_dialog (builder, pager);
		
		g_object_unref (builder);
	}

	gtk_window_set_icon_name (GTK_WINDOW (pager->properties_dialog),
	                          WORKSPACE_SWITCHER_ICON);
	gtk_window_set_screen (GTK_WINDOW (pager->properties_dialog),
			       gtk_widget_get_screen (pager->applet));
	gtk_window_present (GTK_WINDOW (pager->properties_dialog));
}
コード例 #4
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static void
add_recent_project_row (GtkListBox *recent_project_box, GtkRecentData *recent_project)
{
	GtkBuilder *builder;
	GFile *file;
	GtkWidget *recent_row;
	GtkLabel *project_label, *path_label;
	GError *error;

	error = NULL;
	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_resource (builder, "/org/gnome/anjuta/ui/starter.ui", &error))
	{
		DEBUG_PRINT ("Could not load starter.ui! %s", error->message);
		g_error_free (error);
	}
	else
	{
		file = g_file_new_for_uri (gtk_recent_info_get_uri (recent_project));
		if (g_file_query_exists (file, NULL))
		{
			recent_row = GTK_WIDGET (gtk_builder_get_object (builder, RECENT_ROW));
			project_label = GTK_WIDGET (gtk_builder_get_object (builder, PROJECT_LABEL));
			path_label = GTK_WIDGET (gtk_builder_get_object (builder, PATH_LABEL));
			gtk_label_set_text (project_label, gtk_recent_info_get_display_name(recent_project));
			gtk_label_set_text (path_label, g_file_get_path(file));
			g_object_set_data_full (G_OBJECT (recent_row), URI_KEY, g_file_get_uri(file), g_free);
			gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (recent_row)), recent_row);
			gtk_list_box_insert (recent_project_box, recent_row, -1);
		}
		g_object_unref (file);

	}
	g_object_unref (builder);
}
コード例 #5
0
static void
screenshot_application_startup (GApplication *app)
{
  ScreenshotApplication *self = SCREENSHOT_APPLICATION (app);
  GtkBuilder *builder;
  GMenuModel *menu;

  G_APPLICATION_CLASS (screenshot_application_parent_class)->startup (app);

  gtk_window_set_default_icon_name (SCREENSHOOTER_ICON);
  screenshooter_init_stock_icons ();

  g_action_map_add_action_entries (G_ACTION_MAP (self), action_entries,
                                   G_N_ELEMENTS (action_entries), self);

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/org/gnome/screenshot/screenshot-app-menu.ui", NULL);
  menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
  gtk_application_set_app_menu (GTK_APPLICATION (self), menu);

  g_object_unref (builder);
  g_object_unref (menu);

  /* interactive mode: trigger the dialog and wait for the response */
  if (screenshot_config->interactive)
    screenshot_show_interactive_dialog (self);
  else
    screenshot_start (self);
}
コード例 #6
0
static void
terminal_app_startup (GApplication *application)
{
  const GActionEntry app_menu_actions[] = {
    { "preferences", app_menu_preferences_cb,   NULL, NULL, NULL },
    { "help",        app_menu_help_cb,          NULL, NULL, NULL },
    { "about",       app_menu_about_cb,         NULL, NULL, NULL },
    { "quit",        app_menu_quit_cb,          NULL, NULL, NULL }
  };

  gs_unref_object GtkBuilder *builder;
  GError *error = NULL;

  G_APPLICATION_CLASS (terminal_app_parent_class)->startup (application);

  /* Need to set the WM class (bug #685742) */
  gdk_set_program_class("Gnome-terminal");

  g_action_map_add_action_entries (G_ACTION_MAP (application),
                                   app_menu_actions, G_N_ELEMENTS (app_menu_actions),
                                   application);

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder,
                                 TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal-appmenu.ui",
                                 &error);
  g_assert_no_error (error);

  gtk_application_set_app_menu (GTK_APPLICATION (application),
                                G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")));

  _terminal_debug_print (TERMINAL_DEBUG_SERVER, "Startup complete\n");
}
コード例 #7
0
static void
net_connection_editor_init (NetConnectionEditor *editor)
{
        GError *error = NULL;
        GtkTreeSelection *selection;

        editor->builder = gtk_builder_new ();

        gtk_builder_add_from_resource (editor->builder,
                                       "/org/gnome/control-center/network/connection-editor.ui",
                                       &error);
        if (error != NULL) {
                g_warning ("Could not load ui file: %s", error->message);
                g_error_free (error);
                return;
        }

        editor->window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_dialog"));
        selection = GTK_TREE_SELECTION (gtk_builder_get_object (editor->builder,
                                                                "details_page_list_selection"));
        g_signal_connect (selection, "changed",
                          G_CALLBACK (selection_changed), editor);

        editor->scrolled_window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "toplevel_scrolled_window"));
}
コード例 #8
0
ファイル: ConfDlg.c プロジェクト: MaddTheSane/PCSX-Reloaded
void OnConf_Net() {
	GtkWidget *widget;

	if (NetDlg != NULL) {
		gtk_window_present (GTK_WINDOW (NetDlg));
		return;
	}

	builder = gtk_builder_new();
	if (!gtk_builder_add_from_resource(builder, "/org/pcsxr/gui/pcsxr.ui", NULL)) {
		g_warning("Error: interface could not be loaded!");
		return;
	}

	NetDlg = GTK_WIDGET(gtk_builder_get_object(builder, "NetDlg"));
	
	gtk_widget_show (NetDlg);

	FindNetPlugin(builder);

	/* Setup a handler for when Close or Cancel is clicked */
	g_signal_connect_data(G_OBJECT(NetDlg), "response",
			G_CALLBACK(OnNet_Clicked), builder, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);

	widget = GTK_WIDGET(gtk_builder_get_object(builder, "btn_ConfNet"));
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(OnNet_Conf), builder, NULL, G_CONNECT_AFTER);

	widget = GTK_WIDGET(gtk_builder_get_object(builder, "btn_AboutNet"));
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(OnNet_About), builder, NULL, G_CONNECT_AFTER);
}
コード例 #9
0
ファイル: application.c プロジェクト: 3v1n0/gtk
static void
activate (GApplication *app)
{
  GtkBuilder *builder;
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *contents;
  GtkWidget *status;
  GtkWidget *message;
  GtkWidget *button;
  GtkWidget *infobar;
  GtkWidget *menutool;
  GMenuModel *toolmenu;
  GtkTextBuffer *buffer;

  window = gtk_application_window_new (GTK_APPLICATION (app));
  gtk_window_set_title (GTK_WINDOW (window), "Application Class");
  gtk_window_set_icon_name (GTK_WINDOW (window), "document-open");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  g_action_map_add_action_entries (G_ACTION_MAP (window),
                                   win_entries, G_N_ELEMENTS (win_entries),
                                   window);

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/application/application.ui", NULL);

  grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
  contents = (GtkWidget *)gtk_builder_get_object (builder, "contents");
  status = (GtkWidget *)gtk_builder_get_object (builder, "status");
  message = (GtkWidget *)gtk_builder_get_object (builder, "message");
  button = (GtkWidget *)gtk_builder_get_object (builder, "button");
  infobar = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
  menutool = (GtkWidget *)gtk_builder_get_object (builder, "menutool");
  toolmenu = (GMenuModel *)gtk_builder_get_object (builder, "toolmenu");

  g_object_set_data (G_OBJECT (window), "message", message);
  g_object_set_data (G_OBJECT (window), "infobar", infobar);

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menutool),
                                 gtk_menu_new_from_model (toolmenu));

  gtk_widget_grab_focus (contents);
  g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), infobar);

  /* Show text widget info in the statusbar */
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
  g_signal_connect_object (buffer, "changed",
                           G_CALLBACK (update_statusbar), status, 0);
  g_signal_connect_object (buffer, "mark-set",
                           G_CALLBACK (mark_set_callback), status, 0);

  update_statusbar (buffer, GTK_STATUSBAR (status));

  gtk_widget_show_all (window);

  g_object_unref (builder);
}
コード例 #10
0
static void
nautilus_application_init_actions (NautilusApplication *self)
{
	GtkBuilder *builder;
	GError *error = NULL;
	const gchar *debug_no_app_menu;

	g_action_map_add_action_entries (G_ACTION_MAP (self),
					 app_entries, G_N_ELEMENTS (app_entries),
					 self);
	gtk_application_add_accelerator (GTK_APPLICATION (self), "F10", "win.gear-menu", NULL);

	builder = gtk_builder_new ();
	gtk_builder_add_from_resource (builder, "/org/gnome/nautilus/nautilus-app-menu.ui", &error);

	if (error == NULL) {
		gtk_application_set_app_menu (GTK_APPLICATION (self),
					      G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
	} else {
		g_critical ("Unable to add the application menu: %s\n", error->message);
		g_error_free (error);
	}

	g_object_unref (builder);

	debug_no_app_menu = g_getenv ("NAUTILUS_DEBUG_NO_APP_MENU");
	if (debug_no_app_menu) {
		DEBUG ("Disabling app menu GtkSetting as requested...");
		g_object_set (gtk_settings_get_default (),
			      "gtk-shell-shows-app-menu", FALSE,
			      NULL);
	}
}
コード例 #11
0
int main (int argc, char **argv)
{
  GtkBuilder *builder;
  GtkWidget *window;
  GError *error = NULL;

  gtk_init (&argc, &argv);
  g_resources_register (cc_mouse_get_resource ());

  builder = gtk_builder_new ();

  gtk_builder_add_from_resource (builder, "/org/gnome/control-center/mouse/gnome-mouse-test.ui", &error);
  if (error != NULL)
    {
      g_warning ("Error loading UI file: %s", error->message);
      return 1;
    }

  window = gnome_mouse_test_init (builder);
  gtk_widget_show_all (window);

  g_signal_connect (G_OBJECT (window), "delete-event",
  G_CALLBACK (delete_event_cb), window);

  gtk_main ();

  return 0;
}
コード例 #12
0
ファイル: logview-app.c プロジェクト: GNOME/gnome-system-log
static void
logview_app_init_actions (LogviewApp *app)
{
  GtkBuilder *builder = gtk_builder_new ();
  GMenuModel *app_menu;

  g_action_map_add_action_entries (G_ACTION_MAP (app), action_entries,
                                   G_N_ELEMENTS (action_entries), app);

  gtk_builder_add_from_resource (builder, "/org/gnome/logview/logview-app-menu.ui", NULL);
  app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
  gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);

  /* menu accel */
  SIMPLE_ACCEL (app, "F10", "win.gear-menu");

  /* action accels */
  SIMPLE_ACCEL (app, "<Control>f", "win.search");
  SIMPLE_ACCEL (app, "<Control>o", "win.open");
  SIMPLE_ACCEL (app, "<Control>w", "win.close");
  SIMPLE_ACCEL (app, "<Control>c", "win.copy");
  SIMPLE_ACCEL (app, "<Control>a", "win.select_all");
  SIMPLE_ACCEL (app, "<Control>plus", "win.zoom_in");
  SIMPLE_ACCEL (app, "<Control>minus", "win.zoom_out");
  SIMPLE_ACCEL (app, "<Control>0", "win.zoom_normal");

  /* additional zoom accels */
  SIMPLE_ACCEL (app, "<Control>KP_Add", "win.zoom_in");
  SIMPLE_ACCEL (app, "<Control>KP_Subtract", "win.zoom_out");
  SIMPLE_ACCEL (app, "<Control>KP_0", "win.zoom_normal");

  g_object_unref (builder);
  g_object_unref (app_menu);
}
コード例 #13
0
ファイル: RefImplApp.c プロジェクト: cristianadam/io2d
static void refimpl_app_startup(GApplication* application) {
    RefImplApp* app = REFIMPL_APP(application);

    G_APPLICATION_CLASS(refimpl_app_parent_class)->startup(application);

    g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);

    if (refimpl_app_has_app_menu(app)) {
	GtkBuilder* builder;
	GError* error = NULL;

	builder = gtk_builder_new();
	if (!gtk_builder_add_from_resource(builder,
					   "/com/bobtacoindustries/N3888_RefImpl/refimpl_menu.ui",
					   &error)) {
	    g_warning("Loading menu builder file failed. Message: %s", error->message);
	    g_error_free(error);
	}
	else {
	    GMenuModel* appMenu;
	    appMenu = G_MENU_MODEL(gtk_builder_get_object(builder, "app_menu"));
	    gtk_application_set_app_menu(GTK_APPLICATION(application), appMenu);
	}

	g_object_unref(builder);
    }

    //setup_accelerators(app);
}
コード例 #14
0
ファイル: gui.c プロジェクト: MaddTheSane/PCSX-Reloaded
long CFGopen() {
	GtkBuilder *builder;
	GtkWidget *widget, *MainWindow;
	char buf[256];

	LoadConf();

	builder = gtk_builder_new();

	if (!gtk_builder_add_from_resource(builder, "/org/pcsxr/dfnet/dfnet.ui", NULL)) {
		g_warning("We could not load the interface!");
		return 0;
	}

	MainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "dlgStart"));
	gtk_window_set_title(GTK_WINDOW(MainWindow), _("NetPlay"));

	widget = GTK_WIDGET(gtk_builder_get_object(builder, "btnCopyIP"));
	g_signal_connect_data(G_OBJECT(widget), "clicked",
		G_CALLBACK(OnCopyIP), NULL, NULL, G_CONNECT_AFTER);

	widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbServerIP"));
	gtk_entry_set_text(GTK_ENTRY(widget), conf.ipAddress);

	widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbPort"));
	sprintf(buf, "%d", conf.PortNum);
	gtk_entry_set_text(GTK_ENTRY(widget), buf);

	if (conf.PlayerNum == 1) {
		widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbServer"));
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
	} else {
		widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbClient"));
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
	}

	if (gtk_dialog_run(GTK_DIALOG(MainWindow)) == GTK_RESPONSE_OK) {
		widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbServerIP"));
		strcpy(conf.ipAddress, gtk_entry_get_text(GTK_ENTRY(widget)));

		widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbPort"));
		conf.PortNum = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));

		widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbServer"));
		if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
			conf.PlayerNum = 1;
		} else {
			conf.PlayerNum = 2;
		}

		SaveConf();
		gtk_widget_destroy(MainWindow);
		return 1;
	}

	gtk_widget_destroy(MainWindow);

	return 0;
}
コード例 #15
0
GtkWidget *
cc_input_chooser_new (GtkWindow    *main_window,
                      GnomeXkbInfo *xkb_info,
                      GHashTable   *ibus_engines)
{
  GtkBuilder *builder;
  GtkWidget *chooser;
  CcInputChooserPrivate *priv;
  gint width;
  GError *error = NULL;

  builder = gtk_builder_new ();
  if (gtk_builder_add_from_resource (builder, "/org/gnome/initial-setup/input-chooser.ui", &error) == 0)
    {
      g_object_unref (builder);
      g_warning ("failed to load input chooser: %s", error->message);
      g_error_free (error);
      return NULL;
    }
  chooser = WID ("input-dialog");
  priv = g_new0 (CcInputChooserPrivate, 1);
  g_object_set_data_full (G_OBJECT (chooser), "private", priv, cc_input_chooser_private_free);
  g_object_set_data_full (G_OBJECT (chooser), "builder", builder, g_object_unref);

  priv->xkb_info = xkb_info;
  priv->ibus_engines = ibus_engines;

  priv->add_button = WID ("add-button");
  priv->filter_entry = WID ("filter-entry");
  priv->list = WID ("list");
  priv->scrolledwindow = WID ("scrolledwindow");
  priv->adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow));

  priv->more_item = g_object_ref_sink (more_widget_new ());
  priv->no_results = g_object_ref_sink (no_results_widget_new ());

  gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->list), list_filter, chooser, NULL);
  gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->list), list_sort, chooser, NULL);
  g_signal_connect (priv->list, "row-activated", G_CALLBACK (row_activated), chooser);
  g_signal_connect (priv->list, "row-selected", G_CALLBACK (row_selected), chooser);

  g_signal_connect_swapped (priv->filter_entry, "changed", G_CALLBACK (filter_changed), chooser);

  get_locale_infos (chooser);
#ifdef HAVE_IBUS
  get_ibus_locale_infos (chooser);
#endif  /* HAVE_IBUS */
  show_locale_widgets (chooser);

  /* Try to come up with a sensible width */
  gtk_window_get_size (main_window, &width, NULL);
  gtk_widget_set_size_request (chooser, width * MAIN_WINDOW_WIDTH_RATIO, -1);
  gtk_window_set_resizable (GTK_WINDOW (chooser), TRUE);

  gtk_window_set_transient_for (GTK_WINDOW (chooser), main_window);

  return chooser;
}
コード例 #16
0
GtkWidget *
cc_search_locations_dialog_new (CcSearchPanel *self)
{
  GtkWidget *locations_dialog, *widget, *list_box;
  GtkBuilder *dialog_builder;
  GError *error = NULL;

  dialog_builder = gtk_builder_new ();
  gtk_builder_add_from_resource (dialog_builder,
                                 "/org/gnome/control-center/search/search-locations-dialog.ui",
                                 &error);

  if (error != NULL)
    {
      g_warning ("Could not load interface file: %s", error->message);
      g_error_free (error);
      return NULL;
    }

  tracker_preferences = g_settings_new (TRACKER_SCHEMA);

  locations_dialog = GTK_WIDGET (gtk_builder_get_object (dialog_builder, "locations_dialog"));
  widget = GTK_WIDGET (gtk_builder_get_object (dialog_builder, "locations_scrolledwindow"));
  list_box = GTK_WIDGET (egg_list_box_new ());
  egg_list_box_add_to_scrolled (EGG_LIST_BOX (list_box), GTK_SCROLLED_WINDOW (widget));
  egg_list_box_set_sort_func (EGG_LIST_BOX (list_box),
                              place_compare_func, NULL, NULL);
  egg_list_box_set_separator_funcs (EGG_LIST_BOX (list_box),
                                    place_separator_func, NULL, NULL);
  gtk_widget_show (list_box);

  widget = GTK_WIDGET (gtk_builder_get_object (dialog_builder, "locations_remove"));
  gtk_widget_set_sensitive (widget, FALSE);
  g_signal_connect (list_box, "child-selected",
                    G_CALLBACK (list_box_child_selected), widget);
  g_signal_connect (widget, "clicked",
                    G_CALLBACK (remove_button_clicked), list_box);
  g_signal_connect_swapped (tracker_preferences, "changed::" TRACKER_KEY_RECURSIVE_DIRECTORIES,
                            G_CALLBACK (locations_dialog_refresh), list_box);

  widget = GTK_WIDGET (gtk_builder_get_object (dialog_builder, "locations_add"));
  g_signal_connect (widget, "clicked",
                    G_CALLBACK (add_button_clicked), list_box);

  gtk_window_set_transient_for (GTK_WINDOW (locations_dialog),
                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));
  g_signal_connect (locations_dialog, "response",
                    G_CALLBACK (gtk_widget_destroy), NULL);
  g_signal_connect (locations_dialog, "destroy",
                    G_CALLBACK (locations_dialog_destroy), NULL);

  populate_list_box (list_box);

  g_object_unref (dialog_builder);

  return locations_dialog;
}
コード例 #17
0
GtkWidget *
cc_language_chooser_new (GtkWidget *parent)
{
        GtkBuilder *builder;
        GtkWidget *chooser;
        CcLanguageChooserPrivate *priv;
        GError *error = NULL;

        g_resources_register (cc_common_get_resource ());

        builder = gtk_builder_new ();
        if (gtk_builder_add_from_resource (builder, "/org/gnome/control-center/common/language-chooser.ui", &error) == 0) {
                g_object_unref (builder);
                g_warning ("failed to load language chooser: %s", error->message);
                g_error_free (error);
                return NULL;
        }

        chooser = WID ("language-dialog");
        priv = g_new0 (CcLanguageChooserPrivate, 1);
        g_object_set_data_full (G_OBJECT (chooser), "private", priv, cc_language_chooser_private_free);
        g_object_set_data_full (G_OBJECT (chooser), "builder", builder, g_object_unref);

        priv->done_button = WID ("ok-button");
        priv->filter_entry = WID ("language-filter-entry");
        priv->language_list = WID ("language-list");
        priv->scrolledwindow = WID ("language-scrolledwindow");
        priv->more_item = more_widget_new ();
        /* We ref-sink here so we can reuse this widget multiple times */
        priv->no_results = g_object_ref_sink (no_results_widget_new ());
        gtk_widget_show_all (priv->no_results);

        gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->language_list),
                                    sort_languages, chooser, NULL);
        gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->language_list),
                                      language_visible, chooser, NULL);
        gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->language_list),
                                         GTK_SELECTION_NONE);
        gtk_list_box_set_header_func (GTK_LIST_BOX (priv->language_list),
                                      cc_list_box_update_header_func, NULL, NULL);
        add_all_languages (GTK_DIALOG (chooser));

        g_signal_connect_swapped (priv->filter_entry, "search-changed",
                                  G_CALLBACK (filter_changed), chooser);

        g_signal_connect (priv->language_list, "row-activated",
                          G_CALLBACK (row_activated), chooser);

        gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->language_list));

        gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (parent));

        g_signal_connect (chooser, "activate-default",
                          G_CALLBACK (activate_default), chooser);

        return chooser;
}
コード例 #18
0
static void
create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
                                GtkTreeIter *iter, gpointer data)
{
    GsmApplication *app = static_cast<GsmApplication *>(data);
    GtkDialog *openfilesdialog;
    GtkGrid *cmd_grid;
    GtkLabel *label;
    GtkScrolledWindow *scrolled;
    GsmTreeView *tree;
    ProcInfo *info;
    guint timer;

    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);

    if (!info)
        return;

    GtkBuilder *builder = gtk_builder_new();
    gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/openfiles.ui", NULL);

    openfilesdialog = GTK_DIALOG (gtk_builder_get_object (builder, "openfiles_dialog"));

    cmd_grid = GTK_GRID (gtk_builder_get_object (builder, "cmd_grid"));


    label = procman_make_label_for_mmaps_or_ofiles (
        _("_Files opened by process “%s” (PID %u):"),
        info->name.c_str(),
        info->pid);

    gtk_container_add (GTK_CONTAINER (cmd_grid), GTK_WIDGET (label));

    scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "scrolled"));

    tree = create_openfiles_tree (app);
    gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (tree));
    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));

    g_signal_connect (G_OBJECT (openfilesdialog), "response",
                      G_CALLBACK (close_openfiles_dialog), tree);

    gtk_builder_connect_signals (builder, NULL);

    gtk_window_set_transient_for (GTK_WINDOW (openfilesdialog), GTK_WINDOW (GsmApplication::get()->main_window));
    gtk_widget_show_all (GTK_WIDGET (openfilesdialog));

    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));

    update_openfiles_dialog (tree);

    g_object_unref (G_OBJECT (builder));
}
コード例 #19
0
ファイル: main.c プロジェクト: RavikumarTulugu/antkorp
static void
activate (GApplication *app)
{
  GtkBuilder *builder;
  GtkWindow *window;
  GtkWidget *widget;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GError *error = NULL;
  static GActionEntry win_entries[] = {
    { "run", activate_run, NULL, NULL, NULL }
  };

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/ui/main.ui", &error);
  if (error != NULL)
    {
      g_critical ("%s", error->message);
      exit (1);
    }

  window = (GtkWindow *)gtk_builder_get_object (builder, "window");
  gtk_application_add_window (GTK_APPLICATION (app), window);
  g_action_map_add_action_entries (G_ACTION_MAP (window),
                                   win_entries, G_N_ELEMENTS (win_entries),
                                   window);

  notebook = (GtkWidget *)gtk_builder_get_object (builder, "notebook");

  info_view = (GtkWidget *)gtk_builder_get_object (builder, "info-textview");
  source_view = (GtkWidget *)gtk_builder_get_object (builder, "source-textview");
  headerbar = (GtkWidget *)gtk_builder_get_object (builder, "headerbar");
  treeview = (GtkWidget *)gtk_builder_get_object (builder, "treeview");
  model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));

  load_file (gtk_demos[0].name, gtk_demos[0].filename);

  populate_model (model);

  g_signal_connect (treeview, "row-activated", G_CALLBACK (row_activated_cb), model);

  widget = (GtkWidget *)gtk_builder_get_object (builder, "treeview-selection");
  g_signal_connect (widget, "changed", G_CALLBACK (selection_cb), model);

  gtk_tree_model_get_iter_first (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)), &iter);
  gtk_tree_selection_select_iter (GTK_TREE_SELECTION (widget), &iter);

  gtk_tree_view_collapse_all (GTK_TREE_VIEW (treeview));

  gtk_widget_show_all (GTK_WIDGET (window));

  g_object_unref (builder);
}
コード例 #20
0
/**
 * uploads_get_dialog:
 *
 * Returns the a #GtkWindow representing the Uploads window.  If it
 * has not already been created, it creates it.  The Uploads window is
 * set to be hidden instead of destroyed when closed, to avoid having
 * to recreate it and re-parse the UI file, etc.
 **/
static GtkWindow *
uploads_get_dialog (XviewerPostasaPlugin *plugin)
{
	GtkBuilder *builder;
	GError *error = NULL;
	GtkButton *cancel_button;
	GtkButton *cancel_all_button;

	if (plugin->priv->uploads_window == NULL) {
		builder = gtk_builder_new ();
		gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
		gtk_builder_add_from_resource (builder, GTKBUILDER_UPLOAD_FILE,
		                               &error);
		if (error != NULL) {
			g_warning ("Couldn't load Postasa uploads UI file:%d:%s", error->code, error->message);
			g_error_free (error);
			return NULL;
		}

		/* note: do not unref gtk_builder_get_object() returns */
		plugin->priv->uploads_window = GTK_WINDOW     (gtk_builder_get_object (builder, "uploads_window"));
		plugin->priv->uploads_view   = GTK_TREE_VIEW  (gtk_builder_get_object (builder, "uploads_view"));
		plugin->priv->uploads_store  = GTK_LIST_STORE (gtk_builder_get_object (builder, "uploads_store"));

		cancel_button     = GTK_BUTTON (gtk_builder_get_object (builder, "cancel_button"));
		cancel_all_button = GTK_BUTTON (gtk_builder_get_object (builder, "cancel_all_button"));

		/* TODO: can't set expand = TRUE when packing cells into columns via glade-3/GtkBuilder apparently?
		   bgo #602152  So for now, we take them, clear them out, and remap them.  Ugh.  Better solutions welcome.  */
		GtkTreeViewColumn *file_col       = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder, "file_col"));
		GtkCellRenderer   *thumbnail_cell = GTK_CELL_RENDERER    (gtk_builder_get_object (builder, "thumbnail_cell"));
		GtkCellRenderer   *filepath_cell  = GTK_CELL_RENDERER    (gtk_builder_get_object (builder, "filepath_cell"));
		gtk_tree_view_column_clear (file_col);
		gtk_tree_view_column_pack_start (file_col, thumbnail_cell, FALSE);
		gtk_tree_view_column_pack_end (file_col, filepath_cell, TRUE);
		gtk_tree_view_column_add_attribute (file_col, thumbnail_cell, "pixbuf", 0);
		gtk_tree_view_column_add_attribute (file_col, filepath_cell, "text", 1);
		GtkTreeViewColumn *progress_col   = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder, "progress_col"));
		GtkCellRenderer   *progress_cell  = GTK_CELL_RENDERER    (gtk_builder_get_object (builder, "progress_cell"));
		gtk_tree_view_column_clear (progress_col);
		gtk_tree_view_column_pack_end (progress_col, progress_cell, TRUE);
		gtk_tree_view_column_add_attribute (progress_col, progress_cell, "pulse", 3);
		gtk_tree_view_column_add_attribute (progress_col, progress_cell, "text", 5);

		g_object_unref (builder);

		g_signal_connect (G_OBJECT (cancel_button),     "clicked", G_CALLBACK (uploads_cancel_cb), plugin);
		g_signal_connect (G_OBJECT (cancel_all_button), "clicked", G_CALLBACK (uploads_cancel_all_cb), plugin);
		g_signal_connect (G_OBJECT (plugin->priv->uploads_window), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), plugin);
	}

	return plugin->priv->uploads_window;
}
コード例 #21
0
WirelessSecurity *
wireless_security_init (gsize obj_size,
                        WSValidateFunc validate,
                        WSAddToSizeGroupFunc add_to_size_group,
                        WSFillConnectionFunc fill_connection,
                        WSUpdateSecretsFunc update_secrets,
                        WSDestroyFunc destroy,
                        const char *ui_resource,
                        const char *ui_widget_name,
                        const char *default_field)
{
	WirelessSecurity *sec;
	GError *error = NULL;

	g_return_val_if_fail (obj_size > 0, NULL);
	g_return_val_if_fail (ui_resource != NULL, NULL);
	g_return_val_if_fail (ui_widget_name != NULL, NULL);

	sec = g_slice_alloc0 (obj_size);
	g_assert (sec);

	sec->refcount = 1;
	sec->obj_size = obj_size;

	sec->validate = validate;
	sec->add_to_size_group = add_to_size_group;
	sec->fill_connection = fill_connection;
	sec->update_secrets = update_secrets;
	sec->destroy = destroy;
	sec->default_field = default_field;

	sec->builder = gtk_builder_new ();
	if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
		g_warning ("Couldn't load UI builder file %s: %s",
		           ui_resource, error->message);
		g_error_free (error);
		wireless_security_unref (sec);
		return NULL;
	}

	sec->ui_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, ui_widget_name));
	if (!sec->ui_widget) {
		g_warning ("Couldn't load UI widget '%s' from UI file %s",
		           ui_widget_name, ui_resource);
		wireless_security_unref (sec);
		return NULL;
	}
	g_object_ref_sink (sec->ui_widget);

	sec->adhoc_compatible = TRUE;

	return sec;
}
コード例 #22
0
static void
cc_notifications_panel_init (CcNotificationsPanel *panel)
{
  GtkWidget *w;
  GError *error = NULL;

  g_resources_register (cc_notifications_get_resource ());
  panel->known_applications = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                     NULL, g_free);

  panel->builder = gtk_builder_new ();
  if (gtk_builder_add_from_resource (panel->builder,
                                     "/org/gnome/control-center/notifications/notifications.ui",
                                     &error) == 0)
    {
      g_error ("Error loading UI file: %s", error->message);
      g_error_free (error);
      return;
    }

  panel->master_settings = g_settings_new (MASTER_SCHEMA);

  g_settings_bind (panel->master_settings, "show-banners",
                   gtk_builder_get_object (panel->builder, "ccnotify-switch-banners"),
                   "active", G_SETTINGS_BIND_DEFAULT);
  g_settings_bind (panel->master_settings, "show-in-lock-screen",
                   gtk_builder_get_object (panel->builder, "ccnotify-switch-lock-screen"),
                   "active", G_SETTINGS_BIND_DEFAULT);

  panel->list_box = egg_list_box_new ();
  w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
                                          "ccnotify-app-scrolledwindow"));

  egg_list_box_add_to_scrolled (panel->list_box, GTK_SCROLLED_WINDOW (w));
  egg_list_box_set_selection_mode (panel->list_box, GTK_SELECTION_NONE);
  egg_list_box_set_sort_func (panel->list_box, sort_apps, NULL, NULL);
  egg_list_box_set_separator_funcs (panel->list_box,
                                    update_separator_func,
                                    NULL, NULL);

  g_signal_connect (panel->list_box, "child-activated",
                    G_CALLBACK (select_app), panel);

  gtk_widget_set_visible (GTK_WIDGET (panel->list_box), TRUE);

  build_app_store (panel);

  w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
                                          "ccnotify-main-grid"));
  gtk_widget_reparent (w, GTK_WIDGET (panel));
  gtk_widget_show (w);
}
コード例 #23
0
EAPMethod *
eap_method_init (gsize obj_size,
                 EMValidateFunc validate,
                 EMAddToSizeGroupFunc add_to_size_group,
                 EMFillConnectionFunc fill_connection,
                 EMUpdateSecretsFunc update_secrets,
                 EMDestroyFunc destroy,
                 const char *ui_resource,
                 const char *ui_widget_name,
                 const char *default_field,
                 gboolean phase2)
{
	EAPMethod *method;
	GError *error = NULL;

	g_return_val_if_fail (obj_size > 0, NULL);
	g_return_val_if_fail (ui_resource != NULL, NULL);
	g_return_val_if_fail (ui_widget_name != NULL, NULL);

	method = g_slice_alloc0 (obj_size);
	g_assert (method);

	method->refcount = 1;
	method->obj_size = obj_size;
	method->validate = validate;
	method->add_to_size_group = add_to_size_group;
	method->fill_connection = fill_connection;
	method->update_secrets = update_secrets;
	method->default_field = default_field;
	method->phase2 = phase2;

	method->builder = gtk_builder_new ();
	if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) {
		g_warning ("Couldn't load UI builder file %s: %s",
		           ui_resource, error->message);
		eap_method_unref (method);
		return NULL;
	}

	method->ui_widget = GTK_WIDGET (gtk_builder_get_object (method->builder, ui_widget_name));
	if (!method->ui_widget) {
		g_warning ("Couldn't load UI widget '%s' from UI file %s",
		           ui_widget_name, ui_resource);
		eap_method_unref (method);
		return NULL;
	}
	g_object_ref_sink (method->ui_widget);

	method->destroy = destroy;

	return method;
}
コード例 #24
0
GtkWidget *
cc_input_options_new (GtkWidget *parent)
{
        GtkBuilder *builder;
        GtkWidget *options;
        CcInputOptionsPrivate *priv;
        GError *error = NULL;

        builder = gtk_builder_new ();
        if (gtk_builder_add_from_resource (builder, "/org/gnome/control-center/region/input-options.ui", &error) == 0) {
                g_object_unref (builder);
                g_warning ("failed to load input options: %s", error->message);
                g_error_free (error);
                return NULL;
        }

        options = WID ("dialog");
        priv = g_new0 (CcInputOptionsPrivate, 1);
        g_object_set_data_full (G_OBJECT (options), "private", priv, cc_input_options_private_free);
        g_object_set_data_full (G_OBJECT (options), "builder", builder, g_object_unref);

        priv->same_source = WID ("same-source");
        priv->per_window_source = WID ("per-window-source");
        priv->previous_source = WID ("previous-source");
        priv->next_source = WID ("next-source");
        priv->alt_next_source = WID ("alt-next-source");

        g_object_bind_property (priv->previous_source, "visible",
                                WID ("previous-source-label"), "visible",
                                G_BINDING_DEFAULT);
        g_object_bind_property (priv->next_source, "visible",
                                WID ("next-source-label"), "visible",
                                G_BINDING_DEFAULT);
        g_object_bind_property (priv->alt_next_source, "visible",
                                WID ("alt-next-source-label"), "visible",
                                G_BINDING_DEFAULT);

        priv->settings = g_settings_new ("org.gnome.desktop.input-sources");
        g_settings_bind (priv->settings, "per-window",
                         priv->per_window_source, "active",
                         G_SETTINGS_BIND_DEFAULT);
        g_settings_bind (priv->settings, "per-window",
                         priv->same_source, "active",
                         G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);

        update_shortcuts (options);
        update_modifiers_shortcut (options);

        gtk_window_set_transient_for (GTK_WINDOW (options), GTK_WINDOW (parent));

        return options;
}
コード例 #25
0
static void
photos_application_init_app_menu (PhotosApplication *self)
{
  GMenu *menu;
  GtkBuilder *builder;

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/org/gnome/photos/app-menu.ui", NULL);

  menu = G_MENU (gtk_builder_get_object (builder, "app-menu"));
  gtk_application_set_app_menu (GTK_APPLICATION (self), G_MENU_MODEL (menu));
  g_object_unref (builder);
}
コード例 #26
0
GtkWidget *
nma_ethernet_dialog_new (NMConnection *connection)
{
	GtkBuilder *builder;
	GtkWidget *dialog;
	GError *error = NULL;
	WirelessSecurity *security;

	builder = gtk_builder_new ();

	if (!gtk_builder_add_from_resource (builder, "/org/freedesktop/network-manager-applet/8021x.ui", &error)) {
		g_warning ("Couldn't load builder resource: %s", error->message);
		g_error_free (error);
		applet_missing_ui_warning_dialog_show ();
		g_object_unref (builder);
		return NULL;
	}

	dialog = (GtkWidget *) gtk_builder_get_object (builder, "8021x_dialog");
	if (!dialog) {
		g_warning ("Couldn't find wireless_dialog widget.");
		applet_missing_ui_warning_dialog_show ();
		g_object_unref (builder);
		return NULL;
	}

	gtk_window_set_title (GTK_WINDOW (dialog), _("802.1X authentication"));
	gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
	dialog_set_network_name (connection, GTK_ENTRY (gtk_builder_get_object (builder, "network_name_entry")));

	/* Handle CA cert ignore stuff */
	eap_method_ca_cert_ignore_load (connection);

	security = dialog_set_security (connection, builder, GTK_BOX (gtk_builder_get_object (builder, "security_vbox")));
	wireless_security_set_changed_notify (security, stuff_changed_cb, GTK_WIDGET (gtk_builder_get_object (builder, "ok_button")));
	g_object_set_data_full (G_OBJECT (dialog),
	                        "security", security,
	                        (GDestroyNotify) wireless_security_unref);

	g_object_set_data_full (G_OBJECT (dialog),
	                        "connection", g_object_ref (connection),
	                        (GDestroyNotify) g_object_unref);

	/* Ensure the builder gets destroyed when the dialog goes away */
	g_object_set_data_full (G_OBJECT (dialog),
	                        "builder", builder,
	                        (GDestroyNotify) g_object_unref);

	return dialog;
}
コード例 #27
0
static void
cc_language_chooser_constructed (GObject *object)
{
        GtkBuilder *builder;
        CcLanguageChooser *chooser = CC_LANGUAGE_CHOOSER (object);
        CcLanguageChooserPrivate *priv = chooser->priv;
        GError *error = NULL;

        G_OBJECT_CLASS (cc_language_chooser_parent_class)->constructed (object);

        builder = gtk_builder_new ();
        if (gtk_builder_add_from_resource (builder, "/org/gnome/control-center/language-chooser.ui", &error) == 0) {
                g_object_unref (builder);
                g_warning ("failed to load language chooser: %s", error->message);
                g_error_free (error);
                return;
        }

        gtk_container_add (GTK_CONTAINER (chooser), WID ("language-chooser"));

        priv->filter_entry = WID ("language-filter-entry");
        priv->language_list = WID ("language-list");
        priv->more_item = more_widget_new ();
        priv->no_results = no_results_widget_new ();

        gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->language_list),
                                    sort_languages, chooser, NULL);
        gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->language_list),
                                      language_visible, chooser, NULL);
        gtk_list_box_set_header_func (GTK_LIST_BOX (priv->language_list),
                                      update_header_func, chooser, NULL);
        gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->language_list),
                                         GTK_SELECTION_NONE);
        add_all_languages (chooser);

        g_signal_connect (priv->filter_entry, "changed",
                          G_CALLBACK (filter_changed),
                          chooser);

        g_signal_connect (priv->language_list, "row-activated",
                          G_CALLBACK (row_activated), chooser);

        if (priv->language == NULL)
                priv->language = cc_common_language_get_current_language ();

        sync_all_checkmarks (chooser);

        g_object_unref (builder);
}
コード例 #28
0
ファイル: widget-factory.c プロジェクト: rightpeter/gtk-1
static void
startup (GApplication *app)
{
  GtkBuilder *builder;
  GMenuModel *appmenu;

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/ui/widget-factory.ui", NULL);

  appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");

  gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);

  g_object_unref (builder);
}
コード例 #29
0
static void
net_device_ethernet_init (NetDeviceEthernet *device)
{
        GError *error = NULL;

        device->builder = gtk_builder_new ();
        gtk_builder_add_from_resource (device->builder,
                                       "/org/gnome/control-center/network/network-ethernet.ui",
                                       &error);
        if (error != NULL) {
                g_warning ("Could not load interface file: %s", error->message);
                g_error_free (error);
                return;
        }
}
コード例 #30
0
ファイル: bjb-app-menu.c プロジェクト: curiousDTU/bijiben
void bjb_app_menu_set(GApplication *application) 
{
  GtkBuilder *builder;

  g_action_map_add_action_entries (G_ACTION_MAP (application),
                                   app_entries,
                                   G_N_ELEMENTS (app_entries),
                                   application);
    
  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/org/gnome/bijiben/app-menu.ui", NULL);

  gtk_application_set_app_menu (GTK_APPLICATION (application), 
                                G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
  g_object_unref (builder);
}