Esempio n. 1
1
GtkWidget *
hitori_create_interface (Hitori *hitori)
{
	GtkBuilder *builder;
	GtkStyleContext *style_context;
	GtkCssProvider *css_provider;
	const PangoFontDescription *font;
	GAction *action;

	builder = gtk_builder_new_from_resource ("/org/gnome/Hitori/ui/hitori.ui");

	gtk_builder_set_translation_domain (builder, PACKAGE);
	gtk_builder_connect_signals (builder, hitori);

	/* Setup the main window */
	hitori->window = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_main_window"));
	hitori->drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_drawing_area"));
	hitori->timer_label = GTK_LABEL (gtk_builder_get_object (builder, "hitori_timer"));

	g_object_unref (builder);

	/* Set up actions */
	g_action_map_add_action_entries (G_ACTION_MAP (hitori), app_entries, G_N_ELEMENTS (app_entries), hitori);
	g_action_map_add_action_entries (G_ACTION_MAP (hitori->window), win_entries, G_N_ELEMENTS (win_entries), hitori);

	action = g_settings_create_action (hitori->settings, "board-size");
	g_action_map_add_action (G_ACTION_MAP (hitori), action);
	g_signal_connect (G_OBJECT (action), "notify::state", (GCallback) board_size_change_cb, hitori);
	g_object_unref (action);

	hitori->undo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "undo"));
	hitori->redo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "redo"));
	hitori->hint_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "hint"));

	/* Set up font descriptions for the drawing area */
	style_context = gtk_widget_get_style_context (hitori->drawing_area);
	gtk_style_context_get (style_context,
	                       gtk_style_context_get_state (style_context),
	                       GTK_STYLE_PROPERTY_FONT, &font, NULL);
	hitori->normal_font_desc = pango_font_description_copy (font);
	hitori->painted_font_desc = pango_font_description_copy (font);

	/* Load CSS for the drawing area */
	css_provider = gtk_css_provider_new ();
	gtk_css_provider_load_from_resource (css_provider, "/org/gnome/Hitori/ui/hitori.css");
	gtk_style_context_add_provider (style_context, GTK_STYLE_PROVIDER (css_provider),
                                            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	g_object_unref (css_provider);

	/* Reset the timer */
	hitori_reset_timer (hitori);

	/* Disable undo/redo until a cell has been clicked. */
	g_simple_action_set_enabled (hitori->undo_action, FALSE);
	g_simple_action_set_enabled (hitori->redo_action, FALSE);

	return hitori->window;
}
Esempio n. 2
0
static void
show_error_dialogue_cb(GtkInfoBar* info_bar,
                       gint res,
                       gchar** udata)
{
    GtkBuilder* builder = gtk_builder_new_from_resource("/com/vinszent/GnomeTwitch/ui/gt-error-dlg.ui");
    GtkWidget* dlg = GTK_WIDGET(gtk_builder_get_object(builder, "dlg"));
    GtkTextView* details_text_view = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "details_text_view"));

    if (res != GTK_RESPONSE_OK) goto cleanup;

    gtk_text_buffer_set_text(gtk_text_view_get_buffer(details_text_view),
                             *(udata+1), -1);

    g_object_set(dlg,
                 "text", _("Something went wrong"),
                 "secondary-text", *udata,
                 NULL);
    g_signal_connect(dlg, "response", G_CALLBACK(gtk_widget_destroy), NULL);

    gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(GT_WIN_ACTIVE));
    gtk_widget_show(dlg);

cleanup:
    g_strfreev(udata);
}
Esempio n. 3
0
void nick_menu_popup(GdkEventButton *event, const char *nick){
    GList *chats;
    GtkBuilder *builder;
    GtkMenu *nick_menu;
    GtkMenuItem *item;
    GtkMenuItem *whois_menu_item;
    GtkMenuItem *ignore_menu_item;
    GtkMenuItem *kick_menu_item;
    GtkMenuItem *chat_menu_item;
    GtkMenuItem *invite_menu_item;
    SrainChat *chat;

    builder = gtk_builder_new_from_resource ("/org/gtk/srain/nick_menu.glade");

    nick_menu = (GtkMenu *)gtk_builder_get_object(builder, "nick_menu");
    whois_menu_item = (GtkMenuItem *)gtk_builder_get_object(builder, "whois_menu_item");
    ignore_menu_item = (GtkMenuItem *)gtk_builder_get_object(builder, "ignore_menu_item");
    kick_menu_item = (GtkMenuItem *)gtk_builder_get_object(builder, "kick_menu_item");
    chat_menu_item = (GtkMenuItem *)gtk_builder_get_object(builder, "chat_menu_item");
    invite_menu_item = (GtkMenuItem *)gtk_builder_get_object(builder, "invite_menu_item");

    g_signal_connect(whois_menu_item, "activate",
            G_CALLBACK(nick_menu_item_on_activate), (char *)nick);
    g_signal_connect(ignore_menu_item, "activate",
            G_CALLBACK(nick_menu_item_on_activate), (char *)nick);
    g_signal_connect(kick_menu_item, "activate",
            G_CALLBACK(nick_menu_item_on_activate), (char *)nick);
    g_signal_connect(chat_menu_item, "activate",
            G_CALLBACK(nick_menu_item_on_activate), (char *)nick);

    /******************************************/
    chat = srain_window_get_cur_chat(srain_win);
    chats = srain_window_get_chats_by_srv_name(srain_win,
            srain_chat_get_srv_name(chat));

    /* Skip META_SERVER */
    chats = g_list_next(chats);

    /* Create subitem of invite_menu_item */
    GtkMenu *invite_submenu = GTK_MENU(gtk_menu_new());
    gtk_menu_item_set_submenu(invite_menu_item, GTK_WIDGET(invite_submenu));

    while (chats){
        item  = GTK_MENU_ITEM(gtk_menu_item_new_with_label(
                    srain_chat_get_chat_name(chats->data)));
        gtk_widget_show(GTK_WIDGET(item));
        gtk_widget_set_name(GTK_WIDGET(item), "invite_submenu_item");
        g_signal_connect(item, "activate",
                G_CALLBACK(nick_menu_item_on_activate), (char *)nick);
        gtk_menu_shell_append(GTK_MENU_SHELL(invite_submenu), GTK_WIDGET(item));

        chats = g_list_next(chats);
    }
    g_list_free(chats);

    gtk_menu_popup(nick_menu, NULL, NULL, NULL, NULL,
            event->button, event->time);

    g_object_unref(builder);
}
Esempio n. 4
0
static void
gb_color_picker_prefs_palette_row_init (GbColorPickerPrefsPaletteRow *self)
{
  GtkBuilder *builder;
  GtkWidget *button_rename;
  GtkWidget *button_remove;

  gtk_widget_init_template (GTK_WIDGET (self));
  gtk_widget_add_events (self->event_box, GDK_KEY_PRESS_MASK);

  g_signal_connect_swapped (self->event_box, "button-press-event",
                            G_CALLBACK (event_box_button_pressed_cb),
                            self);

  builder = gtk_builder_new_from_resource ("/org/gnome/builder/plugins/color-picker-plugin/gtk/color-picker-palette-menu.ui");
  self->popover_menu = GTK_WIDGET (g_object_ref_sink (gtk_builder_get_object (builder, "popover")));
  button_rename = GTK_WIDGET (gtk_builder_get_object (builder, "button_rename"));
  g_signal_connect_object (button_rename, "button-release-event",
                           G_CALLBACK (popover_button_rename_clicked_cb), self, G_CONNECT_SWAPPED);

  button_remove = GTK_WIDGET (gtk_builder_get_object (builder, "button_remove"));
  g_signal_connect_object (button_remove, "button-release-event",
                           G_CALLBACK (popover_button_remove_clicked_cb), self, G_CONNECT_SWAPPED);

  gtk_popover_set_relative_to (GTK_POPOVER (self->popover_menu), GTK_WIDGET (self));

  g_object_unref (builder);
}
Esempio n. 5
0
static void
cem_application_startup(GApplication * app)
{
  GtkBuilder *builder;
  GMenuModel *app_menu;

  const gchar *quit_accels[2] ={"<Ctrl >Q", NULL};


  G_APPLICATION_CLASS(cem_application_parent_class)->startup(app);

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


  gtk_application_set_accels_for_action(GTK_APPLICATION(app), "app.quit", quit_accels);

  builder = gtk_builder_new_from_resource("/org/bandari/cem/glade/cem_menu.glade");

//  app_menu = G_MENU_MODEL (gtk_builder_get_object(builder, "appmenu"));

//  gtk_application_set_app_menu(GTK_APPLICATION(app), app_menu);

  g_object_unref(builder);
}
Esempio n. 6
0
File: revealer.c Progetto: GNOME/gtk
GtkWidget *
do_revealer (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkBuilder *builder;

      builder = gtk_builder_new_from_resource ("/revealer/revealer.ui");
      gtk_builder_connect_signals (builder, NULL);
      window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (do_widget));
      g_signal_connect (window, "destroy",
                        G_CALLBACK (on_destroy), NULL);
      g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
    }

  if (!gtk_widget_get_visible (window))
    {
      count = 0;
      timeout = g_timeout_add (690, reveal_one, window);
      gtk_widget_show (window);
    }
  else
    {
      gtk_widget_destroy (window);
    }


  return window;
}
Esempio n. 7
0
GtkWidget *
do_theming_style_classes (GtkWidget *do_widget)
{
  GtkWidget *grid;
  GtkBuilder *builder;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Style Classes");
      gtk_container_set_border_width (GTK_CONTAINER (window), 12);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      builder = gtk_builder_new_from_resource ("/theming_style_classes/theming.ui");

      grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
      gtk_widget_show_all (grid);
      gtk_container_add (GTK_CONTAINER (window), grid);
      g_object_unref (builder);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Esempio n. 8
0
GtkWidget*
eog_save_as_dialog_new (GtkWindow *main, GList *images, GFile *base_file)
{
	GtkBuilder  *xml;
	GtkWidget *dlg;
	SaveAsData *data;
	GtkWidget *label;


	xml = gtk_builder_new_from_resource ("/org/gnome/eog/ui/eog-multiple-save-as-dialog.ui");
	gtk_builder_set_translation_domain (xml, GETTEXT_PACKAGE);

	dlg = GTK_WIDGET (g_object_ref (gtk_builder_get_object (xml, "eog_multiple_save_as_dialog")));
	gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (main));
	gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER_ON_PARENT);

	data = g_slice_new0 (SaveAsData);
	/* init widget references */
	data->dir_chooser = GTK_WIDGET (gtk_builder_get_object (xml,
								"dir_chooser"));
	data->token_entry = GTK_WIDGET (gtk_builder_get_object (xml,
								"token_entry"));
	data->replace_spaces_check = GTK_WIDGET (gtk_builder_get_object (xml,
						       "replace_spaces_check"));
	data->counter_spin = GTK_WIDGET (gtk_builder_get_object (xml,
							       "counter_spin"));
	data->preview_label = GTK_WIDGET (gtk_builder_get_object (xml,
							      "preview_label"));
	data->format_combobox = GTK_WIDGET (gtk_builder_get_object (xml,
							    "format_combobox"));

	/* init preview information */
	data->idle_id = 0;
	data->n_images = g_list_length (images);
	data->nth_image = (int) ((float) data->n_images * rand() / (float) (RAND_MAX+1.0));
	g_assert (data->nth_image >= 0 && data->nth_image < data->n_images);
	data->image = g_object_ref (EOG_IMAGE (g_list_nth_data (images, data->nth_image)));
	g_object_set_data_full (G_OBJECT (dlg), "data", data, destroy_data_cb);

	g_signal_connect (G_OBJECT (data->format_combobox), "changed",
			  (GCallback) on_format_combobox_changed, dlg);

	g_signal_connect (G_OBJECT (data->token_entry), "changed",
			  (GCallback) on_token_entry_changed, dlg);

	g_signal_connect (G_OBJECT (data->replace_spaces_check), "toggled",
			  (GCallback) on_replace_spaces_check_clicked, dlg);

	g_signal_connect (G_OBJECT (data->counter_spin), "changed",
			  (GCallback) on_counter_spin_changed, dlg);

	label = GTK_WIDGET (gtk_builder_get_object (xml, "preview_label_from"));
	gtk_label_set_text (GTK_LABEL (label), eog_image_get_caption (data->image));

	prepare_format_combobox (data);

	set_default_values (dlg, base_file);
	g_object_unref (xml);
	return dlg;
}
Esempio n. 9
0
GtkWidget *
do_css_blendmodes (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;

  if (!window)
    {
      GtkStyleProvider *provider;
      GtkBuilder *builder;

      builder = gtk_builder_new_from_resource ("/css_blendmodes/blendmodes.ui");

      window = WID ("window");
      gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
      g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);

      /* Setup the CSS provider for window */
      provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

      gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                                 provider,
                                                 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

      setup_listbox (builder, provider);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Esempio n. 10
0
File: cursors.c Progetto: GNOME/gtk
GtkWidget *
do_cursors (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkBuilder *builder;

      builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
      gtk_builder_connect_signals (builder, NULL);
      window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (do_widget));
      g_signal_connect (window, "destroy",
                        G_CALLBACK (on_destroy), NULL);
      g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show (window);
  else
    {
      gtk_widget_destroy (window);
    }

  return window;
}
Esempio n. 11
0
static GtkBuilder *gtkhash_properties_init_builder(void)
{
#if (GTK_MAJOR_VERSION > 2)
	return gtk_builder_new_from_resource(PROPERTIES_XML_RESOURCE);
#else
	GError *error = NULL;
	GBytes *bytes = g_resources_lookup_data(PROPERTIES_XML_RESOURCE,
		G_RESOURCE_LOOKUP_FLAGS_NONE, &error);

	if (G_UNLIKELY(error)) {
		g_warning("%s", error->message);
		g_error_free(error);

		return NULL;
	}

	gsize xml_len = 0;
	char *xml = g_bytes_unref_to_data(bytes, &xml_len);
	GtkBuilder *builder = gtk_builder_new();

	gtk_builder_add_from_string(builder, xml, xml_len, &error);
	g_free(xml);

	if (G_UNLIKELY(error)) {
		g_warning("%s", error->message);
		g_error_free(error);
		g_object_unref(builder);

		return NULL;
	}

	return builder;
#endif
}
Esempio n. 12
0
static GtkWidget *
create_popover (GtkWidget *child)
{
    GtkBuilder *builder = gtk_builder_new_from_resource ("/org/fsearch/fsearch/popover.ui");
    GtkWidget *popover = GTK_WIDGET (gtk_builder_get_object (builder, "DatabasePopover"));
    gtk_popover_set_relative_to (GTK_POPOVER (popover), child);
    return popover;
}
Esempio n. 13
0
static void
setup_accels_actions_headerbar (PtWindow *win)
{
    /* Actions */
    g_action_map_add_action_entries (G_ACTION_MAP (win),
                                     win_actions,
                                     G_N_ELEMENTS (win_actions),
                                     win);

    enable_win_actions (win, FALSE);

    /* GtkHeader workaround for glade 3.16 + Menu button */
    GtkBuilder    *builder;
    GMenuModel    *model;
    GtkWidget     *hbar;
    GtkWidget     *menu_button;

    builder = gtk_builder_new_from_resource ("/org/gnome/parlatype/window-headerbar.ui");
    hbar = GTK_WIDGET (gtk_builder_get_object (builder, "headerbar"));
    win->priv->button_open = GTK_WIDGET (gtk_builder_get_object (builder, "button_open"));
    win->priv->button_play = GTK_WIDGET (gtk_builder_get_object (builder, "button_play"));
    menu_button = GTK_WIDGET (gtk_builder_get_object (builder, "menu_button"));
    gtk_window_set_titlebar (GTK_WINDOW (win), hbar);
    gtk_builder_connect_signals (builder, win);

    builder = gtk_builder_new_from_resource ("/org/gnome/parlatype/menus.ui");
    model = G_MENU_MODEL (gtk_builder_get_object (builder, "winmenu"));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), model);
    g_object_unref (builder);

    /* Accels */
    GtkAccelGroup *accels;
    accels = gtk_accel_group_new ();
    gtk_window_add_accel_group (GTK_WINDOW (win), accels);

    gtk_widget_add_accelerator (menu_button,
                                "clicked",
                                accels,
                                GDK_KEY_F10,
                                0,
                                GTK_ACCEL_VISIBLE);
}
Esempio n. 14
0
static void
example_app_window_init (ExampleAppWindow *win)
{
  ExampleAppWindowPrivate *priv;
  GtkBuilder *builder;
  GMenuModel *menu;
  GAction *action;

  priv = example_app_window_get_instance_private (win);
  gtk_widget_init_template (GTK_WIDGET (win));
  priv->settings = g_settings_new ("com.lonelycactus.exampleapp");

  g_settings_bind (priv->settings, "transition",
                   priv->stack, "transition-type",
                   G_SETTINGS_BIND_DEFAULT);

  g_settings_bind (priv->settings, "show-words",
                   priv->sidebar, "reveal-child",
                   G_SETTINGS_BIND_DEFAULT);

  g_object_bind_property (priv->search, "active",
                          priv->searchbar, "search-mode-enabled",
                          G_BINDING_BIDIRECTIONAL);

  g_signal_connect (priv->connect, "toggled",
                    G_CALLBACK (toggle_server), win);

  g_signal_connect (priv->sidebar, "notify::reveal-child",
                    G_CALLBACK (words_changed), win);

  builder = gtk_builder_new_from_resource ("/com/lonelycactus/exampleapp/gears-menu.ui");
  menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
  g_object_unref (builder);

  action = g_settings_create_action (priv->settings, "show-words");
  g_action_map_add_action (G_ACTION_MAP (win), action);
  g_object_unref (action);

  action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
  g_action_map_add_action (G_ACTION_MAP (win), action);
  g_object_unref (action);

  g_object_bind_property (priv->lines, "visible",
                          priv->lines_label, "visible",
                          G_BINDING_DEFAULT);

  service_init();
  service_start_accepting_new_connections();

  g_object_set (gtk_settings_get_default (), "gtk-shell-shows-app-menu", FALSE, NULL);
  gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (win), TRUE);
}
Esempio n. 15
0
GtkBuilder *virt_viewer_util_load_ui(const char *name)
{
    GtkBuilder *builder;
    gchar *resource = g_strdup_printf("%s/ui/%s",
                                      VIRT_VIEWER_RESOURCE_PREFIX,
                                      name);

    builder = gtk_builder_new_from_resource(resource);

    g_free(resource);
    return builder;
}
Esempio n. 16
0
static GtkWidget*
setup_popover (VteTerminal *vtterm)
{
    GtkWidget *popover = gtk_popover_new (GTK_WIDGET (vtterm));
    g_signal_connect (G_OBJECT (popover), "closed",
                      G_CALLBACK (popover_closed), vtterm);

    dg_lobj GtkBuilder *builder = gtk_builder_new_from_resource (DWT_GRESOURCE ("menus.xml"));
    gtk_popover_bind_model (GTK_POPOVER (popover),
                            G_MENU_MODEL (gtk_builder_get_object (builder, "popover-menu")),
                            NULL);
    return popover;
}
Esempio n. 17
0
static void
glarea_app_startup (GApplication *app)
{
  GtkBuilder *builder;
  GMenuModel *app_menu;

  G_APPLICATION_CLASS (glarea_app_parent_class)->startup (app);

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

  builder = gtk_builder_new_from_resource ("/io/bassi/glarea/glarea-app-menu.ui");
  app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
  gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
  g_object_unref (builder);
}
Esempio n. 18
0
void
bookmarks__gth_browser_construct_cb (GthBrowser *browser)
{
    BrowserData *data;

    g_return_if_fail (GTH_IS_BROWSER (browser));

    data = g_new0 (BrowserData, 1);
    g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);

    g_action_map_add_action_entries (G_ACTION_MAP (browser),
                                     actions,
                                     G_N_ELEMENTS (actions),
                                     browser);

    {
        GtkWidget  *button;
        GMenuModel *menu;

        button = _gtk_menu_button_new_for_header_bar ("user-bookmarks-symbolic");
        gtk_widget_set_tooltip_text (button, _("Bookmarks"));

        data->builder = gtk_builder_new_from_resource ("/org/gnome/gThumb/bookmarks/data/ui/bookmarks-menu.ui");
        data->system_bookmarks_menu = G_MENU (gtk_builder_get_object (data->builder, "system-bookmarks"));
        data->entry_points_menu = G_MENU (gtk_builder_get_object (data->builder, "entry-points"));
        data->bookmarks_menu = G_MENU (gtk_builder_get_object (data->builder, "bookmarks"));

        menu = G_MENU_MODEL (gtk_builder_get_object (data->builder, "bookmarks-menu"));
        gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
        _gtk_window_add_accelerators_from_menu ((GTK_WINDOW (browser)), menu);

        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (gth_browser_get_headerbar_section (browser, GTH_BROWSER_HEADER_SECTION_BROWSER_LOCATIONS)), button, FALSE, FALSE, 0);
    }

    data->browser = browser;
    data->bookmarks_changed_id = g_signal_connect (gth_main_get_default_monitor (),
                                 "bookmarks-changed",
                                 G_CALLBACK (bookmarks_changed_cb),
                                 data);
    data->entry_points_changed_id = g_signal_connect (gth_main_get_default_monitor (),
                                    "entry-points-changed",
                                    G_CALLBACK (entry_points_changed_cb),
                                    data);
}
Esempio n. 19
0
static void
example_app_window_init (ExampleAppWindow *win)
{
  ExampleAppWindowPrivate *priv;
  GtkBuilder *builder;
  GMenuModel *menu;
  GAction *action;

  priv = example_app_window_get_instance_private (win);
  gtk_widget_init_template (GTK_WIDGET (win));
  priv->settings = g_settings_new ("org.gtk.exampleapp");

  g_settings_bind (priv->settings, "transition",
                   priv->stack, "transition-type",
                   G_SETTINGS_BIND_DEFAULT);

  g_settings_bind (priv->settings, "show-words",
                   priv->sidebar, "reveal-child",
                   G_SETTINGS_BIND_DEFAULT);

  g_object_bind_property (priv->search, "active",
                          priv->searchbar, "search-mode-enabled",
                          G_BINDING_BIDIRECTIONAL);

  g_signal_connect (priv->sidebar, "notify::reveal-child",
                    G_CALLBACK (words_changed), win);

  builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
  menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
  g_object_unref (builder);

  action = g_settings_create_action (priv->settings, "show-words");
  g_action_map_add_action (G_ACTION_MAP (win), action);
  g_object_unref (action);

  action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
  g_action_map_add_action (G_ACTION_MAP (win), action);
  g_object_unref (action);

  g_object_bind_property (priv->lines, "visible",
                          priv->lines_label, "visible",
                          G_BINDING_DEFAULT);
}
Esempio n. 20
0
static void gonepass_app_startup(GApplication * app) {
    GtkBuilder * builder;
    GMenuModel * app_menu;
    const char * quit_accels[2] = { "<Ctrl>Q", NULL };
    const char * lock_accels[2] = { "<Ctrl>L", NULL };
    const char * refresh_accels[3] = { "F5", "<Ctrl>R", NULL };

    G_APPLICATION_CLASS(gonepass_app_parent_class)->startup(app);
    g_action_map_add_action_entries(G_ACTION_MAP(app),
        app_entries, G_N_ELEMENTS(app_entries), app);
    gtk_application_set_accels_for_action(GTK_APPLICATION(app), "app.quit", quit_accels);
    gtk_application_set_accels_for_action(GTK_APPLICATION(app), "app.lock", lock_accels);
    gtk_application_set_accels_for_action(GTK_APPLICATION(app), "app.refresh", refresh_accels);

    builder = gtk_builder_new_from_resource("/org/gtk/gonepass/appmenu.ui");
    app_menu = G_MENU_MODEL(gtk_builder_get_object(builder, "appmenu"));
    gtk_application_set_app_menu(GTK_APPLICATION(app), app_menu);
    g_object_unref(builder);
}
Esempio n. 21
0
GtkWidget *
do_modelbutton (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;
  static GActionEntry win_entries[] = {
    { "color", NULL, "s", "'red'", NULL },
    { "chocolate", NULL, NULL, "true", NULL },
    { "vanilla", NULL, NULL, "false", NULL },
    { "sprinkles", NULL, NULL, NULL, NULL }
  };

  if (!window)
    {
      GtkBuilder *builder;
      GActionGroup *actions;

      builder = gtk_builder_new_from_resource ("/modelbutton/modelbutton.ui");
      gtk_builder_add_callback_symbol (builder, "tool_clicked", G_CALLBACK (tool_clicked));
      gtk_builder_connect_signals (builder, NULL);
      window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      actions = (GActionGroup*)g_simple_action_group_new ();
      g_action_map_add_action_entries (G_ACTION_MAP (actions),
                                       win_entries, G_N_ELEMENTS (win_entries),
                                       window);
      gtk_widget_insert_action_group (window, "win", actions);


      g_object_unref (builder);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    gtk_widget_destroy (window);


  return window;
}
Esempio n. 22
0
static void
rombrowser_app_window_init (RomBrowserAppWindow *win)
{
  RomBrowserAppWindowPrivate *priv;
  GMenuModel *gearsmenu;
  GtkBuilder *builder;

  priv = rombrowser_app_window_get_instance_private (win);
  gtk_widget_init_template (GTK_WIDGET (win));
  priv->settings =  g_settings_new ("org.hotvic.rombrowser.preferences.ui");

  g_object_bind_property (priv->search, "active",
                          priv->searchbar, "search-mode-enabled",
                          G_BINDING_BIDIRECTIONAL
                          );

  builder = gtk_builder_new_from_resource ("/org/hotvic/rombrowser/ui/menu.ui");
  gearsmenu = G_MENU_MODEL (gtk_builder_get_object (builder, "gearsmenu"));
  gtk_menu_button_set_menu_model (priv->gears, gearsmenu);
}
Esempio n. 23
0
void
export_tools__gth_browser_construct_cb (GthBrowser *browser)
{
	GtkBuilder *builder;
	GMenuModel *menu;
	GtkWidget  *button;

	g_return_if_fail (GTH_IS_BROWSER (browser));

	builder = gtk_builder_new_from_resource ("/org/gnome/gThumb/export_tools/data/ui/export-menu.ui");
	gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_WEB_EXPORTERS, G_MENU (gtk_builder_get_object (builder, "web-exporters")));
	gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_OTHER_EXPORTERS, G_MENU (gtk_builder_get_object (builder, "other-exporters")));
	menu = G_MENU_MODEL (gtk_builder_get_object (builder, "export-menu"));

	button = _gtk_menu_button_new_for_header_bar ();
	gtk_widget_set_tooltip_text (button, _("Export"));
	gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("export-symbolic", GTK_ICON_SIZE_MENU));
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
	gtk_widget_show_all (button);
	gtk_box_pack_start (GTK_BOX (gth_browser_get_headerbar_section (browser, GTH_BROWSER_HEADER_SECTION_BROWSER_TOOLS)), button, FALSE, FALSE, 0);
}
Esempio n. 24
0
static void
seahorse_keyserver_results_constructed (GObject *obj)
{
    SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj);
    GtkWindow *window = GTK_WINDOW (self);
    g_autofree gchar* title = NULL;

    G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->constructed (obj);

    if (g_utf8_strlen (self->search_string, -1) == 0) {
        title = g_strdup (_("Remote keys"));
    } else {
        title = g_strdup_printf (_("Remote keys containing “%s”"), self->search_string);
    }

    gtk_window_set_default_size (window, 640, 476);
    gtk_window_set_title (window, title);
    gtk_widget_set_visible (GTK_WIDGET (window), TRUE);

    g_signal_connect (window, "delete-event",
                      G_CALLBACK (on_delete_event), self);

    self->builder = gtk_builder_new_from_resource ("/org/gnome/Seahorse/seahorse-keyserver-results.ui");
    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
                       GTK_WIDGET (gtk_builder_get_object (self->builder, "keyserver-results")));

    /* init key list */
    self->key_list = GTK_LIST_BOX (gtk_builder_get_object (self->builder, "key_list"));
    gtk_list_box_set_header_func (self->key_list, key_list_header_func, NULL, NULL);
    g_signal_connect_object (self->key_list, "row-activated",
                             G_CALLBACK (on_row_activated), self, 0);
    gtk_widget_show (GTK_WIDGET (self->key_list));

    /* Make sure the listbox gets updated with the collection */
    g_signal_connect_object (self->collection, "added",
                             G_CALLBACK (on_item_added), self, 0);

    /* Set focus to the current key list */
    gtk_widget_grab_focus (GTK_WIDGET (self->key_list));
}
Esempio n. 25
0
GtkBuilder *EvalWindowNew(void)
{
	GtkBuilder *EvalWindow = gtk_builder_new_from_resource(GladeFile);

	g_signal_connect(
		gtk_builder_get_object(EvalWindow, "EvalWindow"),
		"delete_event",
		G_CALLBACK(gtk_main_quit),
		NULL);
	g_signal_connect(
		gtk_builder_get_object(EvalWindow, "CalculateButton"),
		"clicked",
		G_CALLBACK(Calculate),
		EvalWindow);
	g_signal_connect(
		gtk_builder_get_object(EvalWindow, "Input"),
		"activate",
		G_CALLBACK(Calculate),
		EvalWindow);

	return EvalWindow;
}
Esempio n. 26
0
static void
dss_app_startup (GApplication * app)
{
  GtkBuilder *builder;
  GMenuModel *app_menu;
  const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };

  G_APPLICATION_CLASS (dss_app_parent_class)->startup (app);

  /* Setup app menu and accels */
  g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries,
      G_N_ELEMENTS (app_entries), app);
  gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit",
      quit_accels);

  builder = gtk_builder_new_from_resource (APPMENU_FILE);
  app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
  gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
  g_object_unref (builder);

  /* Initialize gstreamer only once per application */
  gst_init (NULL, NULL);
}
Esempio n. 27
0
void
list_tools__gth_browser_construct_cb (GthBrowser *browser)
{
	BrowserData *data;
	GtkBuilder  *builder;
	GMenuModel  *menu;
	GtkWidget   *button;

	g_return_if_fail (GTH_IS_BROWSER (browser));

	data = g_new0 (BrowserData, 1);
	data->browser = browser;
	g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);

	g_action_map_add_action_entries (G_ACTION_MAP (browser),
					 actions,
					 G_N_ELEMENTS (actions),
					 browser);

	builder = gtk_builder_new_from_resource ("/org/gnome/gThumb/list_tools/data/ui/tools-menu.ui");
	gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_TOOLS, G_MENU (gtk_builder_get_object (builder, "tools1")));
	gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_MORE_TOOLS, G_MENU (gtk_builder_get_object (builder, "tools2")));
	gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_TOOLS3, G_MENU (gtk_builder_get_object (builder, "tools3")));
	menu = G_MENU_MODEL (gtk_builder_get_object (builder, "tools-menu"));

	/* browser tools */

	button = _gtk_menu_button_new_for_header_bar ();
	g_signal_connect (button, "toggled", G_CALLBACK (tools_menu_button_toggled_cb), data);
	gtk_widget_set_tooltip_text (button, _("Tools"));
	gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("tools-symbolic", GTK_ICON_SIZE_MENU));
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
	gtk_widget_show_all (button);
	gtk_box_pack_start (GTK_BOX (gth_browser_get_headerbar_section (browser, GTH_BROWSER_HEADER_SECTION_BROWSER_TOOLS)), button, FALSE, FALSE, 0);

	g_object_unref (builder);
}
Esempio n. 28
0
static void
fsearch_application_window_init (FsearchApplicationWindow *self)
{
    g_assert (FSEARCH_WINDOW_IS_WINDOW (self));

    gtk_widget_init_template (GTK_WIDGET (self));

    GtkCssProvider *provider = gtk_css_provider_new ();
    gtk_css_provider_load_from_resource (provider, "/org/fsearch/fsearch/shared.css");
    gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                    GTK_STYLE_PROVIDER (provider),
                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_object_unref (provider);

    create_view_and_model (self);
    //self->selection_popover = create_popover (self->selection_toggle_button);
    //g_signal_connect (self->selection_popover,
    //                  "closed",
    //                  G_CALLBACK (set_toggle_button),
    //                  (gpointer)self->selection_toggle_button);
    self->database_popover = create_popover (self->database_toggle_button);
    fill_database_popover (self->database_popover);
    g_signal_connect (self->database_popover,
                      "closed",
                      G_CALLBACK (set_toggle_button),
                      (gpointer)self->database_toggle_button);

    FsearchApplication *app = FSEARCH_APPLICATION_DEFAULT;
    g_signal_connect (app,
                      "database-update",
                      G_CALLBACK (update_database_cb),
                      self);
    g_signal_connect (app,
                      "database-updated",
                      G_CALLBACK (updated_database_cb),
                      self);

    g_signal_connect (gtk_icon_theme_get_default (),
                      "changed",
                      G_CALLBACK (icon_theme_changed_cb),
                      self);

    GtkBuilder *builder = gtk_builder_new_from_resource ("/org/fsearch/fsearch/overlay.ui");

    // Overlay when no search results are found
    self->no_search_results_overlay = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                          "no_search_results"));
    gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay),
                             self->no_search_results_overlay);

    // Overlay when database is empty
    self->empty_database_overlay = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                       "empty_database"));
    gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay),
                             self->empty_database_overlay);

    // Overlay when search query is empty
    self->empty_search_query_overlay = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                           "empty_search_query"));
    gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay),
                             self->empty_search_query_overlay);

    // Overlay when database is updating
    self->database_updating_overlay = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                           "database_updating"));
    gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay),
                             self->database_updating_overlay);
    self->database_updating_label = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                        "database_updating_label"));

    g_object_unref (builder);
}
Esempio n. 29
0
static gboolean
on_listview_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
    //printf("popup menu\n");
    g_return_val_if_fail (user_data != NULL, FALSE);
    g_return_val_if_fail (event != NULL, FALSE);

    if (G_UNLIKELY (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)))) {
        // clicked outside of list (e.g. column header)
        return FALSE;
    }

    if (event->type == GDK_BUTTON_PRESS)
    {
        if (event->button == GDK_BUTTON_SECONDARY)
        {
            GtkTreeView *view = GTK_TREE_VIEW (widget);

            GtkTreePath *path = NULL;
            GtkTreeSelection *selection = gtk_tree_view_get_selection (view);

            if ((event->state & gtk_accelerator_get_default_mod_mask ()) == 0
                && !gtk_tree_view_get_path_at_pos (view,
                                                   event->x,
                                                   event->y,
                                                   &path,
                                                   NULL,
                                                   NULL,
                                                   NULL))
            {
                // clicked empty area
                gtk_tree_selection_unselect_all (selection);
                return FALSE;
            }

            if (!path) {
                return FALSE;
            }

            if (!gtk_tree_selection_path_is_selected (selection, path)) {
                gtk_tree_selection_unselect_all (selection);
                gtk_tree_selection_select_path (selection, path);
            }

            GtkBuilder *builder = gtk_builder_new_from_resource ("/org/fsearch/fsearch/menus.ui");

            fill_open_with_menu (GTK_TREE_VIEW (widget), builder, path);

            GMenu *menu_root = G_MENU (gtk_builder_get_object (builder,
                                                               "fsearch_listview_popup_menu"));
            GtkWidget *menu_widget = gtk_menu_new_from_model (G_MENU_MODEL (menu_root));
            gtk_menu_attach_to_widget (GTK_MENU (menu_widget),
                    GTK_WIDGET (widget),
                    NULL);
            gtk_menu_popup (GTK_MENU (menu_widget), NULL, NULL, NULL, NULL,
                    event->button, event->time);

            g_object_unref (builder);
            return TRUE;
        }
    }
    else if (event->type == GDK_2BUTTON_PRESS) {
        if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
            GtkTreeViewColumn *column = NULL;
            GtkTreePath *path = NULL;
            gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
                                           event->x,
                                           event->y,
                                           &path,
                                           &column,
                                           NULL,
                                           NULL);
            if (path) {
                gtk_tree_path_free(path);
            }
        }
    }

    return FALSE;
}
Esempio n. 30
0
/**
 * gs_shell_setup:
 */
void
gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *cancellable)
{
	GsShellPrivate *priv = gs_shell_get_instance_private (shell);
	GtkWidget *widget;

	g_return_if_fail (GS_IS_SHELL (shell));

	priv->plugin_loader = g_object_ref (plugin_loader);
	g_signal_connect (priv->plugin_loader, "updates-changed",
			  G_CALLBACK (gs_shell_updates_changed_cb), shell);
	priv->cancellable = g_object_ref (cancellable);

	gs_shell_monitor_permission (shell);

	/* get UI */
	priv->builder = gtk_builder_new_from_resource ("/org/gnome/Software/gnome-software.ui");
	priv->main_window = GTK_WINDOW (gtk_builder_get_object (priv->builder, "window_software"));
	g_signal_connect (priv->main_window, "map",
			  G_CALLBACK (gs_shell_main_window_mapped_cb), shell);

	/* add application specific icons to search path */
	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
					   GS_DATA G_DIR_SEPARATOR_S "icons");

	g_signal_connect (priv->main_window, "delete-event",
			  G_CALLBACK (main_window_closed_cb), shell);

	/* fix up the header bar */
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));
	g_object_ref (widget);
	gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
	gtk_window_set_titlebar (GTK_WINDOW (priv->main_window), widget);
	g_object_unref (widget);

	/* global keynav */
	g_signal_connect_after (priv->main_window, "key_press_event",
				G_CALLBACK (window_key_press_event), shell);
	/* mouse hardware back button */
	g_signal_connect_after (priv->main_window, "button_press_event",
				G_CALLBACK (window_button_press_event), shell);

	/* setup buttons */
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_shell_back_button_cb), shell);
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_all"));
	g_object_set_data (G_OBJECT (widget),
			   "gnome-software::overview-mode",
			   GINT_TO_POINTER (GS_SHELL_MODE_OVERVIEW));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_shell_overview_button_cb), shell);
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_installed"));
	g_object_set_data (G_OBJECT (widget),
			   "gnome-software::overview-mode",
			   GINT_TO_POINTER (GS_SHELL_MODE_INSTALLED));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_shell_overview_button_cb), shell);
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates"));
	g_object_set_data (G_OBJECT (widget),
			   "gnome-software::overview-mode",
			   GINT_TO_POINTER (GS_SHELL_MODE_UPDATES));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_shell_overview_button_cb), shell);

	priv->shell_overview = GS_SHELL_OVERVIEW (gtk_builder_get_object (priv->builder, "shell_overview"));
	gs_shell_overview_setup (priv->shell_overview,
				 shell,
				 priv->plugin_loader,
				 priv->builder,
				 priv->cancellable);
	priv->shell_updates = GS_SHELL_UPDATES (gtk_builder_get_object (priv->builder, "shell_updates"));
	gs_shell_updates_setup (priv->shell_updates,
				shell,
				priv->plugin_loader,
				priv->builder,
				priv->cancellable);
	priv->shell_installed = GS_SHELL_INSTALLED (gtk_builder_get_object (priv->builder, "shell_installed"));
	gs_shell_installed_setup (priv->shell_installed,
				  shell,
				  priv->plugin_loader,
				  priv->builder,
				  priv->cancellable);
	priv->shell_moderate = GS_SHELL_MODERATE (gtk_builder_get_object (priv->builder, "shell_moderate"));
	gs_shell_moderate_setup (priv->shell_moderate,
				 shell,
				 priv->plugin_loader,
				 priv->builder,
				 priv->cancellable);
	priv->shell_search = GS_SHELL_SEARCH (gtk_builder_get_object (priv->builder, "shell_search"));
	gs_shell_search_setup (priv->shell_search,
			       shell,
			       priv->plugin_loader,
			       priv->builder,
			       priv->cancellable);
	priv->shell_details = GS_SHELL_DETAILS (gtk_builder_get_object (priv->builder, "shell_details"));
	gs_shell_details_setup (priv->shell_details,
				shell,
				priv->plugin_loader,
				priv->builder,
				priv->cancellable);
	priv->shell_category = GS_SHELL_CATEGORY (gtk_builder_get_object (priv->builder, "shell_category"));
	gs_shell_category_setup (priv->shell_category,
				 shell,
				 priv->plugin_loader,
				 priv->builder,
				 priv->cancellable);
	priv->shell_extras = GS_SHELL_EXTRAS (gtk_builder_get_object (priv->builder, "shell_extras"));
	gs_shell_extras_setup (priv->shell_extras,
				 shell,
				 priv->plugin_loader,
				 priv->builder,
				 priv->cancellable);

	/* set up search */
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
	g_signal_connect (GTK_EDITABLE (widget), "activate",
			  G_CALLBACK (gs_shell_search_activated_cb), shell);
	g_signal_connect (priv->main_window, "key-press-event",
			  G_CALLBACK (window_keypress_handler), shell);
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
	g_signal_connect (widget, "key-press-event",
			  G_CALLBACK (entry_keypress_handler), shell);
	g_signal_connect (widget, "search-changed",
			  G_CALLBACK (search_changed_handler), shell);

	/* load content */
	g_signal_connect (priv->shell_overview, "refreshed",
			  G_CALLBACK (initial_overview_load_done), shell);
}