コード例 #1
0
static gboolean
headerbarui_init () {
    GtkWindow *mainwin;
    GtkWidget *menubar;
    GtkWidget *menubtn_image;
    GtkBuilder *builder;

    mainwin = GTK_WINDOW (gtkui_plugin->get_mainwin ());

    menubar = lookup_widget (GTK_WIDGET(mainwin), "menubar");
    g_assert_nonnull(mainwin);
    g_assert_nonnull(menubar);

    builder = gtk_builder_new_from_resource("/org/deadbeef/headerbarui/headerbar.ui");
    headerbar = gtk_builder_get_object(builder, "headerbar1");
    volbutton = gtk_builder_get_object(builder, "volumebutton1");
    headerbar_menubtn =  gtk_builder_get_object(builder, "menubutton1");
    headerbar_seekbar = gtk_builder_get_object(builder, "scale1");
    headerbar_playbtn = gtk_builder_get_object(builder, "playbtn");
    headerbar_pausebtn = gtk_builder_get_object(builder, "pausebtn");

    gtk_widget_show(headerbar);

    gtk_window_set_titlebar(mainwin, GTK_WIDGET(headerbar));

    if (!headerbarui_flag_embed_menubar)
    {
        GtkMenu *menu;
        gtk_widget_hide(menubar);

        headerbarui_update_menubutton();

        gtk_widget_set_can_focus(headerbar_menubtn, FALSE);
        gtk_widget_show (headerbar_menubtn);
    } else {
        gtk_widget_destroy(headerbar_menubtn);
        gtk_widget_reparent(menubar, headerbar);
    }

    if (!headerbarui_flag_show_seek_bar)
    {
        gtk_widget_hide(headerbar_seekbar);
    }

    float volume = deadbeef->volume_get_min_db()-deadbeef->volume_get_db();
    g_assert_false((volume>0));
    gtk_scale_button_set_adjustment(GTK_SCALE_BUTTON (volbutton),
        gtk_adjustment_new (volume, 0, (int)-deadbeef->volume_get_min_db (), 5, 5, 0));

    gtk_widget_show(volbutton);

    gtk_builder_add_callback_symbols(builder,
        "on_volbutton_value_changed", on_volbutton_value_changed,
        "on_nextbtn_clicked", on_nextbtn_clicked,
        "on_prevbtn_clicked", on_prevbtn_clicked,
        "on_pausebtn_clicked", on_pausebtn_clicked,
        "on_playbtn_clicked", on_playbtn_clicked,
        "on_stopbtn_clicked", on_stopbtn_clicked,
        "on_seekbar_format_value", on_seekbar_format_value,
        "on_seekbar_button_press_event", on_seekbar_button_press_event,
        "on_seekbar_button_release_event", on_seekbar_button_release_event,
        NULL);
    gtk_builder_connect_signals(builder, NULL);

    return FALSE;
}
コード例 #2
0
NautilusCompressDialogController *
nautilus_compress_dialog_controller_new (GtkWindow         *parent_window,
                                         NautilusDirectory *destination_directory,
                                         gchar             *initial_name)
{
    NautilusCompressDialogController *self;
    g_autoptr (GtkBuilder) builder = NULL;
    GtkWidget *compress_dialog;
    GtkWidget *error_revealer;
    GtkWidget *error_label;
    GtkWidget *name_entry;
    GtkWidget *activate_button;
    GtkWidget *description_stack;
    GtkWidget *zip_radio_button;
    GtkWidget *tar_xz_radio_button;
    GtkWidget *seven_zip_radio_button;
    NautilusCompressionFormat format;

    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-compress-dialog.ui");
    compress_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "compress_dialog"));
    error_revealer = GTK_WIDGET (gtk_builder_get_object (builder, "error_revealer"));
    error_label = GTK_WIDGET (gtk_builder_get_object (builder, "error_label"));
    name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
    activate_button = GTK_WIDGET (gtk_builder_get_object (builder, "activate_button"));
    zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "zip_radio_button"));
    tar_xz_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_radio_button"));
    seven_zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_radio_button"));
    description_stack = GTK_WIDGET (gtk_builder_get_object (builder, "description_stack"));

    gtk_window_set_transient_for (GTK_WINDOW (compress_dialog),
                                  parent_window);

    self = g_object_new (NAUTILUS_TYPE_COMPRESS_DIALOG_CONTROLLER,
                         "error-revealer", error_revealer,
                         "error-label", error_label,
                         "name-entry", name_entry,
                         "activate-button", activate_button,
                         "containing-directory", destination_directory, NULL);

    self->compress_dialog = compress_dialog;
    self->zip_radio_button = zip_radio_button;
    self->tar_xz_radio_button = tar_xz_radio_button;
    self->seven_zip_radio_button = seven_zip_radio_button;
    self->description_stack = description_stack;
    self->name_entry = name_entry;

    self->response_handler_id = g_signal_connect (compress_dialog,
                                                  "response",
                                                  (GCallback) compress_dialog_controller_on_response,
                                                  self);

    gtk_builder_add_callback_symbols (builder,
                                      "zip_radio_button_on_toggled",
                                      G_CALLBACK (zip_radio_button_on_toggled),
                                      "tar_xz_radio_button_on_toggled",
                                      G_CALLBACK (tar_xz_radio_button_on_toggled),
                                      "seven_zip_radio_button_on_toggled",
                                      G_CALLBACK (seven_zip_radio_button_on_toggled),
                                      NULL);
    gtk_builder_connect_signals (builder, self);

    format = g_settings_get_enum (nautilus_compression_preferences,
                                  NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT);

    update_selected_format (self, format);

    if (initial_name != NULL)
    {
        gtk_entry_set_text (GTK_ENTRY (name_entry), initial_name);
    }

    gtk_widget_show_all (compress_dialog);

    return self;
}