示例#1
0
WaitDialog::WaitDialog(int milliseconds, int width, int height)
{
  waitdialog = gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(waitdialog), _("Please wait ..."));
  gtk_window_set_position(GTK_WINDOW(waitdialog), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal(GTK_WINDOW(waitdialog), TRUE);
  if (width && height)
    gtk_window_set_default_size(GTK_WINDOW(waitdialog), width, height);

  dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG(waitdialog));
  gtk_widget_show(dialog_vbox1);

  vbox1 = gtk_vbox_new(FALSE, 0);
  gtk_widget_show(vbox1);
  gtk_box_pack_start(GTK_BOX(dialog_vbox1), vbox1, TRUE, TRUE, 0);

  label1 = gtk_label_new(_("Please hold on ... processing data"));
  gtk_widget_show(label1);
  gtk_box_pack_start(GTK_BOX(vbox1), label1, FALSE, FALSE, 0);

  dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG(waitdialog));
  gtk_widget_show(dialog_action_area1);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);

  g_timeout_add(milliseconds, GSourceFunc(static_on_timeout), gpointer(this));
}
void RemoteRepositoryAssistant::on_entry_repository ()
{
  if (ignore_entry_repository_changed)
    return;
  gw_destroy_source(event_id_entry_repository);
  event_id_entry_repository = g_timeout_add_full(G_PRIORITY_DEFAULT, 1000, GSourceFunc(on_entry_changed_timeout), gpointer(this), NULL);
}
void WindowCheckKeyterms::text_changed (Editor2 * editor)
// To be called when the text in any of the USFM editors changed.
{
  gw_destroy_source (text_changed_event_id);
  text_changed_event_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 500, GSourceFunc (on_text_changed_timeout), gpointer (this), NULL);
  my_editor = editor;
}
void CNewFilesBox::PushMessage(tEventCode event, gchar *text)
{
	tMessage *msg = (tMessage*)g_malloc(sizeof(tMessage));
	msg->event = event;
	msg->text = text;
	g_async_queue_push(m_Queue, msg);
	g_idle_add(GSourceFunc(idle_func), this);
}
void Selection::_schedule_modified(SPObject */*obj*/, guint flags) {
    if (!this->_idle) {
        /* Request handling to be run in _idle loop */
        this->_idle = g_idle_add_full(SP_SELECTION_UPDATE_PRIORITY, GSourceFunc(&Selection::_emit_modified), this, NULL);
    }

    /* Collect all flags */
    this->_flags |= flags;
}
示例#6
0
bool on_timeout (gpointer data)
{
  // Open maintenance database.
  sqlite3 *db;
  sqlite3_open(maintenance_db_filename, &db);
  sqlite3_busy_timeout(db, 2000);

  // First do the shell commands, as these do contain the commands that we'd like to run.
  // If these shell commands were done later on, and the user would cancel the maintenance
  // routine, then some important shell commands would not be done.
  bool something_was_done = handle_shell_command (db);

  // Tasks related to the git repository.
  if (!something_was_done) {
    something_was_done = handle_git_repositories (db);
  }

  // Tasks related to the snapshots. Done before databases.
  if (!something_was_done) {
    something_was_done = handle_snapshots (db);
  }
 
  // Tasks related to the databases.
  if (!something_was_done) {
    something_was_done = handle_databases (db);
  }

  // Earlier tasks here could have added shell commands, therefore check whether there are any to be done.
  if (!something_was_done) {
    something_was_done = handle_shell_command (db);
  }

  if (something_was_done) {
    // There could be more tasks to be done, let's go for another round.
    g_timeout_add(10, GSourceFunc(on_timeout), NULL);
  } else {
    // All maintenance tasks have been done.
    gtk_main_quit ();
  }

  // Close database.
  sqlite3_close(db);

  // Done.
  return false;
}
示例#7
0
gboolean FloatingWindow::on_status_bar_motion_notify (GdkEventMotion *event)
{
  if (resizing_window) {
    gw_destroy_source (resize_event_id);
    resize_event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 200, GSourceFunc(on_resize_timeout), gpointer(this), NULL);
    gtk_widget_hide (vbox_client);
    guint layout_width, layout_height;
    gtk_layout_get_size (GTK_LAYOUT (layout), &layout_width, &layout_height);
    gint event_x = event->x_root;
    gint event_y = event->y_root;
    if (previous_root_x >= 0) {
      bool resize_box = false;
      if (event_x != previous_root_x) {
        guint new_width = my_gdk_rectangle.width + event_x - previous_root_x;
        // Window should not become too narrow, or too wide for the screen.
        if (new_width >= 100) {
          if ((my_gdk_rectangle.x + new_width) <= layout_width) {
            my_gdk_rectangle.width = new_width;
            resize_box = true;
          }
        }
      }
      if (event_y != previous_root_y) {
        guint new_height = my_gdk_rectangle.height + event_y - previous_root_y;
        // Window should not become too short, or too tall for the screen.
        if (new_height >= 100) {
          if ((my_gdk_rectangle.y + new_height) <= layout_height) {
            my_gdk_rectangle.height = new_height;
            resize_box = true;
          }
        }
      }
      if (resize_box) {
        gtk_widget_set_size_request (vbox_window, my_gdk_rectangle.width, my_gdk_rectangle.height);
      }
    }
    previous_root_x = event_x;
    previous_root_y = event_y;
  }
  return false;
}
示例#8
0
/**
 * 接收文件函数.
 *@param dlgpr 对话框类
 *
 */
void DialogPeer::ReceiveFile(DialogPeer *dlgpr)
{
    GtkWidget *widget;
    GtkTreeModel *model;
    GtkTreeIter iter;
    gchar *filename, *filepath;
    FileInfo *file;
    pthread_t pid;

    filepath = pop_save_path(GTK_WIDGET(dlgpr->grpinf->dialog));
    g_free(progdt.path);
    progdt.path = filepath;
    /* 考察数据集中是否存在项 */
    widget = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset), "file-to-receive-treeview-widget"));
    model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
    if(!model)
        return;
    if (!gtk_tree_model_get_iter_first(model, &iter))
            return;
    dlgpr->torcvsize = 0;
    /* 将选中的项投入文件数据接收类 */
    do {
            gtk_tree_model_get(model, &iter,2, &filename,
                                             5, &file, -1);
            g_free(file->filepath);
            file->filepath = g_strdup_printf("%s%s%s", filepath,
                             *(filepath + 1) != '\0' ? "/" : "",
                             filename);
            pthread_create(&pid, NULL, ThreadFunc(ThreadRecvFile), file);
            pthread_detach(pid);
            g_free(filename);
            dlgpr->torcvsize += file->filesize;
    } while (gtk_tree_model_iter_next(model, &iter));
    dlgpr->rcvdsize = 0;
    dlgpr->timerrcv = g_timeout_add(300, GSourceFunc(UpdataEnclosureRcvUI), dlgpr);
}
示例#9
0
void ShowNotesDialog::restart_timeout ()
{
  gw_destroy_source(event_id);
  event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, GSourceFunc(on_timeout), gpointer(this), NULL);
}
示例#10
0
void WindowMerge::editors_changed()
// This function is called if any of the Editors changed.
{
  gw_destroy_source(editors_changed_event_id);
  editors_changed_event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 500, GSourceFunc(on_editors_changed_timeout), gpointer(this), NULL);
}
示例#11
0
void WindowMerge::load_gui_delayer()
{
  gw_destroy_source(load_gui_event_id);
  load_gui_event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 10, GSourceFunc(on_load_gui_timeout), gpointer(this), NULL);
}
示例#12
0
bool on_timeout (gpointer data)
{
  if (folders.empty()) {
    message ("");
    message (_("Ready."));
    message (_("You can close the window, or it will close itself in 5 minutes."));
    g_timeout_add (300000, GSourceFunc(exit_timeout), NULL);
  } else {
    string folder = folders[0];
    folders.pop_front ();

    // Keep going round and round in circles ...
    folders.push_back(folder);

    if (folder.empty() ) {
      if (we_loop) {
        message (_("Will send and receive again after 5 minutes."));
        message (_("Or close the window to not send and receive again."));
        g_timeout_add(300000, GSourceFunc(on_timeout), NULL);
      } else {
      message (_("Finished"));
      message (_("You can close the window, or it will close itself in 5 minutes."));
        g_timeout_add (300000, GSourceFunc(exit_timeout), NULL);
      }

    } else { 

      message (folder);

      // Tell git about the default method for pushing.
      {
        TinySpawn spawn ("git");
        spawn.arg ("config");
        spawn.arg ("push.default");
        spawn.arg ("matching");
        spawn.workingdirectory (folder);
        spawn.run ();
      }
    
      // Add everything because things could have been added or changed.
      {
        TinySpawn spawn ("git");
        spawn.arg ("add");
        spawn.arg (".");
        spawn.workingdirectory (folder);
        spawn.run ();
      }
    
      // Show status.
      {
        TinySpawn spawn ("git");
        spawn.arg ("status");
        spawn.workingdirectory (folder);
        spawn.read ();
        spawn.run ();
        for (unsigned int i = 0; i < spawn.standardout.size(); i++) {
          message (spawn.standardout[i]);
        }
        for (unsigned int i = 0; i < spawn.standarderr.size(); i++) {
          message (spawn.standarderr[i]);
        }
      }
    
      // Commit changes locally.
      {
        TinySpawn spawn ("git");
        spawn.arg ("commit");
        spawn.arg ("-a");
        spawn.arg ("-m");
        spawn.arg ("Send and receive");
        spawn.workingdirectory (folder);
        spawn.read ();
        spawn.run ();
        for (unsigned int i = 0; i < spawn.standardout.size(); i++) {
          message (spawn.standardout[i]);
        }
        for (unsigned int i = 0; i < spawn.standarderr.size(); i++) {
          message (spawn.standarderr[i]);
        }
      }
    
      // Pull changes from the remote repository.
      {
        TinySpawn spawn ("git");
        spawn.arg ("pull");
        spawn.workingdirectory (folder);
        spawn.read ();
        spawn.run ();
        // Normal operation: Exit status = 0.
        // Merge conflict: Exit status = 256.
        // Remote repository unavailable: Exit status = 256.
        // Conclusion: The exit status cannot be used conclusively for finding out about a merge conflict.
        bool merge_conflict = false;
        for (unsigned int i = 0; i < spawn.standardout.size(); i++) {
          if (spawn.standardout[i].find ("CONFLICT") != string::npos) {
            merge_conflict = true;
          }
          message (spawn.standardout[i]);
        }
        for (unsigned int i = 0; i < spawn.standarderr.size(); i++) {
          message (spawn.standarderr[i]);
        }
        if (merge_conflict) {
          message (_("Bibledit will resolve conflicts between its own data and the data on the server."));
          // Resolve merge conflict.
          TinySpawn mergetool ("php");
          string script;
          gchar *name;
          name = g_build_filename (PACKAGE_DATA_DIR, "conflictcli.php", NULL);
          script = name;
          g_free(name);
          mergetool.arg (script);
          mergetool.arg (folder);
          mergetool.read ();
          mergetool.run ();
          for (unsigned int i = 0; i < mergetool.standardout.size(); i++) {
            message (mergetool.standardout[i]);
          }
          for (unsigned int i = 0; i < mergetool.standarderr.size(); i++) {
            message (mergetool.standarderr[i]);
          }
        }
      }
    
      // Push changes to the remote repository.
      {
        TinySpawn spawn ("git");
        spawn.arg ("push");
        spawn.workingdirectory (folder);
        spawn.read ();
        spawn.run ();
        for (unsigned int i = 0; i < spawn.standardout.size(); i++) {
          message (spawn.standardout[i]);
        }
        for (unsigned int i = 0; i < spawn.standarderr.size(); i++) {
          message (spawn.standarderr[i]);
        }
      }
  
      // Next folder.
      g_timeout_add(500, GSourceFunc(on_timeout), NULL);
    
    }

  }

  return false;
}
示例#13
0
int main (int argc, char *argv[])
{
  // Internationalization: initialize gettext
  bindtextdomain(GETTEXT_PACKAGE, BIBLEDIT_LOCALEDIR);
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  textdomain(GETTEXT_PACKAGE);
  
#ifndef WIN32
  // Do not run as root.
  if (getuid () == 0) {
    cout << _("Bibledit-Git has not been designed to run with root privileges.") << endl;
    return 1;
  }
#endif

  // Initialize Gtk.
  gtk_init (&argc, &argv);

  // Display the window.      
  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), _("Bibledit-Git"));
  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
  gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
  g_signal_connect ((gpointer) window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);

  GtkWidget * scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  GtkWidget * vbox = gtk_vbox_new(FALSE,1);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_container_add (GTK_CONTAINER (vbox), scrolledwindow);

  textview = gtk_text_view_new ();
  gtk_container_add (GTK_CONTAINER (scrolledwindow), textview);
  gtk_widget_set_size_request (textview, 640, 480);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD_CHAR);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), false);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), false);

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));

  GtkWidget * checkbutton = gtk_check_button_new_with_mnemonic (_("_Repeat at end"));
  g_signal_connect ((gpointer) checkbutton, "toggled", G_CALLBACK (on_checkbutton_loop_toggled), NULL);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton), true);
  gtk_container_add(GTK_CONTAINER (vbox), checkbutton);

  message (_("Sending and receiving Bibles."));
  
  gtk_widget_show_all (window);

  // Read the folders to run git on.
  for (int i = 1; i < argc; i++) {
    folders.push_back (argv[i]);
  }
  folders.push_back ("");

  // Wait shortly, then process the data.
  g_timeout_add(2000, GSourceFunc(on_timeout), NULL);

  // Main loop.
  gtk_main();

  // Done.  
  return 0;
}
示例#14
0
void names_on_dbus_changed ()
{
  destroy_source (event_id_rescan_bus);
  event_id_rescan_bus = g_timeout_add_full(G_PRIORITY_DEFAULT, 200, GSourceFunc(on_rescan_bus_timeout), NULL, NULL);
}
示例#15
0
int main (int argc, char *argv[])
{
  // Init variables.
  action_count = 0;
  
#ifndef WIN32
  // Do not run as root.
  if (getuid () == 0)
    return 1;
#endif

  // Redirect stdout and stderr to file.
  if (argc > 2) {
    // When a file is opened it is always allocated the lowest available file 
    // descriptor. Therefore the following commands cause stdout to be 
    // redirected to the logfile.
    close(1);
    creat (argv[2], 0666); 
    // The dup() routine makes a duplicate file descriptor for an already opened 
    // file using the first available file descriptor. Therefore the following 
    // commands cause stderr to be redirected to the file stdout writes to.
    close(2);
    if (dup(1));
  }    

  // Database to read commands from.
  if (argc > 1) maintenance_db_filename = argv[1];
  if (maintenance_db_filename == NULL) 
    return 1;
  if (!g_file_test(maintenance_db_filename, G_FILE_TEST_IS_REGULAR))
    return 1;

  // Initialize Gtk.
  gtk_init (&argc, &argv);

  // Display the window.      
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Bibledit");
  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
  gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
  g_signal_connect ((gpointer) window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);

  GtkWidget * vbox = gtk_vbox_new (FALSE, 10);
  gtk_widget_show (vbox);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 30);

  label = gtk_label_new ("Tidying up");
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  label = gtk_label_new ("");
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  GtkWidget * button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  g_signal_connect ((gpointer) button, "clicked", G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show_all (window);

  // Wait shortly, then process the data.
  g_timeout_add(2000, GSourceFunc(on_timeout), NULL);

  // Main loop.
  gtk_main();

  // Remove the maintenance database.
  unlink (maintenance_db_filename);

  // Done.  
  return 0;
}
示例#16
0
int main(int argc, char **argv)
{
    if (initDecoderWithFile(filename))
        return -1;

    init_queue(&video_pkt_queue); //初始化视频数据包队列
    init_queue(&video_pic_queue); //初始化视频图像队列
    init_queue(&audio_pkt_queue);
    init_queue(&audio_sam_queue);
    
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);//设置线程分离属性

    //文件处理线程
    if (0 != pthread_create(&file_tid, &attr, demux, (void*)filename))
        printf("create file handler thread failed!\n");

    //视频解码线程
    if (0 != pthread_create(&dec_tid, &attr, video_decoder, NULL))
        printf("create decode thread failed!\n");

    if (0 != pthread_create(&audio_dec_tid, &attr, audio_decoder, NULL))
        printf("create audio decode thread failed!\n");

    if (0 != pthread_create(&audio_render_tid, &attr, audio_player, NULL))
        printf("create audio render thread failed!\n");

    /*以下是Gtk界面相关代码*/
    if (!g_thread_supported())
        g_thread_init(NULL);

    gdk_threads_init();
    gdk_threads_enter();

    GtkWidget *main_win;//主窗口
    //GtkWidget *drawable;//图像绘制区域
    gtk_init(&argc, &argv);

    char win_title[100];
    sprintf(win_title, "AniPlayer--by Excalibur : %s", filename);
    main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(main_win), win_title);
    GtkWidget *drawable = gtk_drawing_area_new();

    gtk_container_add(GTK_CONTAINER(main_win), drawable);
    g_signal_connect(G_OBJECT(main_win), "delete-event", G_CALLBACK(exit_clean), NULL);
    //gtk_signal_connect(GTK_OBJECT(drawable), "expose-event", G_CALLBACK(on_darea_expose), NULL);

    gtk_widget_show_all(main_win);

    gtk_widget_set_size_request(drawable, g_player_ctx->width, g_player_ctx->height);

    //关闭自动刷新和双缓冲
    gtk_widget_set_app_paintable(drawable, TRUE);
    gtk_widget_set_double_buffered(drawable, FALSE);//此乃大坑,之前没disable掉一直刷白屏

    time_out = gtk_timeout_add(40, GSourceFunc(on_timer), drawable);

    gtk_main();

    gdk_threads_leave();
    
    _CrtDumpMemoryLeaks();

    //getchar();
    return 0;
}
示例#17
0
SelectBooksDialog::SelectBooksDialog(bool showportions, GtkWindow *parent)
/*
This dialog selects books.
This function takes the book from the project that is now open, and
the language of that project.
It then loads the books.
bookset: Indicator for the caller's relevant books.
*/
{
    // Initialize variables.
    extern Settings *settings;
    myproject = settings->genconfig.project_get();
    ProjectConfiguration *projectconfig = settings->projectconfig(myproject);
    mylanguage = projectconfig->language_get();
    myselectables = project_get_books(myproject);
    myshowportions = showportions;

    // Build dialog.
    Shortcuts shortcuts(0);

    selectbooksdialog = gtk_dialog_new();
    ustring title(_("Select books"));
    if (showportions) {
        title.append(_(" and portions"));
    }
    gtk_window_set_title(GTK_WINDOW(selectbooksdialog), title.c_str());
    gtk_window_set_transient_for(GTK_WINDOW(selectbooksdialog), parent);
    gtk_window_set_position(GTK_WINDOW(selectbooksdialog), GTK_WIN_POS_CENTER_ALWAYS); // was GTK_WIN_POS_CENTER_ON_PARENT
    gtk_window_set_modal(GTK_WINDOW(selectbooksdialog), TRUE);

    dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG(selectbooksdialog));
    gtk_widget_show(dialog_vbox1);

    vbox1 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox1);
    gtk_box_pack_start(GTK_BOX(dialog_vbox1), vbox1, TRUE, TRUE, 0);

    hbox11 = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox11);
    gtk_box_pack_start(GTK_BOX(vbox1), hbox11, TRUE, TRUE, 0);

    vbox2 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox2);
    gtk_box_pack_start(GTK_BOX(hbox11), vbox2, TRUE, TRUE, 0);

    labelbooks = gtk_label_new(_("Books"));
    gtk_widget_show(labelbooks);
    gtk_box_pack_start(GTK_BOX(vbox2), labelbooks, FALSE, FALSE, 0);

    shortcuts.label(labelbooks);

    scrolledwindowbooks = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_show(scrolledwindowbooks);
    gtk_box_pack_start(GTK_BOX(vbox2), scrolledwindowbooks, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindowbooks), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindowbooks), GTK_SHADOW_IN);

    treeviewbooks = gtk_tree_view_new();
    gtk_widget_show(treeviewbooks);
    gtk_container_add(GTK_CONTAINER(scrolledwindowbooks), treeviewbooks);
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeviewbooks), FALSE);

    vbox3 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox3);
    gtk_box_pack_start(GTK_BOX(hbox11), vbox3, TRUE, TRUE, 0);

    if (myshowportions) {

        labelportions = gtk_label_new(_("Portions"));
        gtk_widget_show(labelportions);
        gtk_box_pack_start(GTK_BOX(vbox3), labelportions, FALSE, FALSE, 0);

        shortcuts.label(labelportions);

        scrolledwindowportions = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scrolledwindowportions);
        gtk_box_pack_start(GTK_BOX(vbox3), scrolledwindowportions, TRUE, TRUE, 0);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindowportions), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindowportions), GTK_SHADOW_IN);

        treeviewportions = gtk_tree_view_new();
        gtk_widget_show(treeviewportions);
        gtk_container_add(GTK_CONTAINER(scrolledwindowportions), treeviewportions);
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeviewportions), FALSE);

    }

    table1 = gtk_table_new(2, 3, FALSE);
    gtk_widget_show(table1);
    gtk_box_pack_start(GTK_BOX(vbox1), table1, FALSE, FALSE, 0);

    nobutton = gtk_button_new();
    gtk_widget_show(nobutton);
    gtk_table_attach(GTK_TABLE(table1), nobutton, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment1);
    gtk_container_add(GTK_CONTAINER(nobutton), alignment1);

    hbox4 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox4);
    gtk_container_add(GTK_CONTAINER(alignment1), hbox4);

    image1 = gtk_image_new_from_stock("gtk-clear", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image1);
    gtk_box_pack_start(GTK_BOX(hbox4), image1, FALSE, FALSE, 0);

    label6 = gtk_label_new_with_mnemonic(_("No books"));
    gtk_widget_show(label6);
    gtk_box_pack_start(GTK_BOX(hbox4), label6, FALSE, FALSE, 0);

    shortcuts.label(label6);

    otbutton = gtk_button_new();
    gtk_widget_show(otbutton);
    gtk_table_attach(GTK_TABLE(table1), otbutton, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment2);
    gtk_container_add(GTK_CONTAINER(otbutton), alignment2);

    hbox5 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox5);
    gtk_container_add(GTK_CONTAINER(alignment2), hbox5);

    image2 = gtk_image_new_from_stock("gtk-goto-first", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image2);
    gtk_box_pack_start(GTK_BOX(hbox5), image2, FALSE, FALSE, 0);

    label7 = gtk_label_new_with_mnemonic(_("Old Testament"));
    gtk_widget_show(label7);
    gtk_box_pack_start(GTK_BOX(hbox5), label7, FALSE, FALSE, 0);

    shortcuts.label(label7);

    ntbutton = gtk_button_new();
    gtk_widget_show(ntbutton);
    gtk_table_attach(GTK_TABLE(table1), ntbutton, 2, 3, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment3 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment3);
    gtk_container_add(GTK_CONTAINER(ntbutton), alignment3);

    hbox6 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox6);
    gtk_container_add(GTK_CONTAINER(alignment3), hbox6);

    image3 = gtk_image_new_from_stock("gtk-goto-last", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image3);
    gtk_box_pack_start(GTK_BOX(hbox6), image3, FALSE, FALSE, 0);

    label8 = gtk_label_new_with_mnemonic(_("New Testament"));
    gtk_widget_show(label8);
    gtk_box_pack_start(GTK_BOX(hbox6), label8, FALSE, FALSE, 0);

    shortcuts.label(label8);

    otherbutton = gtk_button_new();
    gtk_widget_show(otherbutton);
    gtk_table_attach(GTK_TABLE(table1), otherbutton, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment6 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment6);
    gtk_container_add(GTK_CONTAINER(otherbutton), alignment6);

    hbox9 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox9);
    gtk_container_add(GTK_CONTAINER(alignment6), hbox9);

    image6 = gtk_image_new_from_stock("gtk-dialog-warning", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image6);
    gtk_box_pack_start(GTK_BOX(hbox9), image6, FALSE, FALSE, 0);

    label11 = gtk_label_new_with_mnemonic(_("Other books"));
    gtk_widget_show(label11);
    gtk_box_pack_start(GTK_BOX(hbox9), label11, FALSE, FALSE, 0);

    shortcuts.label(label11);

    allbutton = gtk_button_new();
    gtk_widget_show(allbutton);
    gtk_table_attach(GTK_TABLE(table1), allbutton, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment4 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment4);
    gtk_container_add(GTK_CONTAINER(allbutton), alignment4);

    hbox7 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox7);
    gtk_container_add(GTK_CONTAINER(alignment4), hbox7);

    image4 = gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image4);
    gtk_box_pack_start(GTK_BOX(hbox7), image4, FALSE, FALSE, 0);

    label9 = gtk_label_new_with_mnemonic(_("All books"));
    gtk_widget_show(label9);
    gtk_box_pack_start(GTK_BOX(hbox7), label9, FALSE, FALSE, 0);

    shortcuts.label(label9);

    currentbutton = gtk_button_new();
    gtk_widget_show(currentbutton);
    gtk_table_attach(GTK_TABLE(table1), currentbutton, 2, 3, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);

    alignment5 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment5);
    gtk_container_add(GTK_CONTAINER(currentbutton), alignment5);

    hbox8 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox8);
    gtk_container_add(GTK_CONTAINER(alignment5), hbox8);

    image5 = gtk_image_new_from_stock("gtk-properties", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image5);
    gtk_box_pack_start(GTK_BOX(hbox8), image5, FALSE, FALSE, 0);

    label10 = gtk_label_new_with_mnemonic(_("Current book"));
    gtk_widget_show(label10);
    gtk_box_pack_start(GTK_BOX(hbox8), label10, FALSE, FALSE, 0);

    shortcuts.label(label10);

    dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG(selectbooksdialog));
    gtk_widget_show(dialog_action_area1);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);

    const gchar *helpfile;
    if (showportions) {
        helpfile = "file/print/portion";
    } else {
        helpfile = "file/print/selection";
    }
    new InDialogHelp(selectbooksdialog, NULL, &shortcuts, helpfile);

    cancelbutton = gtk_button_new_from_stock("gtk-cancel");
    gtk_widget_show(cancelbutton);
    gtk_dialog_add_action_widget(GTK_DIALOG(selectbooksdialog), cancelbutton, GTK_RESPONSE_CANCEL);
    gtk_widget_set_can_default (GTK_WIDGET (cancelbutton), true);

    shortcuts.stockbutton(cancelbutton);

    okbutton = gtk_button_new_from_stock("gtk-ok");
    gtk_widget_show(okbutton);
    gtk_dialog_add_action_widget(GTK_DIALOG(selectbooksdialog), okbutton, GTK_RESPONSE_OK);
    gtk_widget_set_can_default (GTK_WIDGET (okbutton), true);

    shortcuts.stockbutton(okbutton);

    shortcuts.process();

    g_signal_connect((gpointer) treeviewbooks, "key_press_event", G_CALLBACK(on_treeviewbooks_key_press_event), gpointer(this));
    if (myshowportions) {
        g_signal_connect((gpointer) treeviewportions, "row_activated", G_CALLBACK(on_treeviewportions_row_activated), gpointer(this));
    }
    g_signal_connect((gpointer) nobutton, "clicked", G_CALLBACK(on_nobutton_clicked), gpointer(this));
    g_signal_connect((gpointer) otbutton, "clicked", G_CALLBACK(on_otbutton_clicked), gpointer(this));
    g_signal_connect((gpointer) ntbutton, "clicked", G_CALLBACK(on_ntbutton_clicked), gpointer(this));
    g_signal_connect((gpointer) otherbutton, "clicked", G_CALLBACK(on_otherbutton_clicked), gpointer(this));
    g_signal_connect((gpointer) allbutton, "clicked", G_CALLBACK(on_allbutton_clicked), gpointer(this));
    g_signal_connect((gpointer) currentbutton, "clicked", G_CALLBACK(on_currentbutton_clicked), gpointer(this));
    g_signal_connect((gpointer) okbutton, "clicked", G_CALLBACK(on_okbutton_clicked), gpointer(this));

    gtk_widget_grab_focus(treeviewbooks);
    gtk_widget_grab_default(okbutton);

    gtk_label_set_mnemonic_widget(GTK_LABEL(labelbooks), treeviewbooks);
    if (myshowportions)
        gtk_label_set_mnemonic_widget(GTK_LABEL(labelportions), treeviewportions);

    // Storage, renderer, column and selection for books.
    {
        storebooks = gtk_list_store_new(1, G_TYPE_STRING);
        gtk_tree_view_set_model(GTK_TREE_VIEW(treeviewbooks), GTK_TREE_MODEL(storebooks));
        g_object_unref(storebooks);
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
        columnbooks = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(treeviewbooks), columnbooks);
        selectbooks = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeviewbooks));
        gtk_tree_selection_set_mode(selectbooks, GTK_SELECTION_MULTIPLE);
    }

    // Storage, renderer, column and selection for portions.
    if (myshowportions) {
        storeportions = gtk_list_store_new(1, G_TYPE_STRING);
        gtk_tree_view_set_model(GTK_TREE_VIEW(treeviewportions), GTK_TREE_MODEL(storeportions));
        g_object_unref(storeportions);
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
        columnportions = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(treeviewportions), columnportions);
        selectportions = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeviewportions));
        gtk_tree_selection_set_mode(selectportions, GTK_SELECTION_SINGLE);
    }
    // Load content.
    myselectables = project_get_books(myproject);
    loadbooks();
    if (myshowportions)
        loadportions();

    // Update gui.
    update_gui_event_id = 0;
    if (myshowportions) {
        update_gui_event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, GSourceFunc(on_update_gui_timeout), gpointer(this), NULL);
    }

    new DialogAutoScaler (selectbooksdialog, G_MAXINT);
}
示例#18
0
void MergeDialog::on_textbuffer()
{
  gw_destroy_source(event_textbuffer);
  event_textbuffer = g_timeout_add_full(G_PRIORITY_DEFAULT, 200, GSourceFunc(on_textbuffer_delayed), gpointer(this), NULL);
}
示例#19
0
void FiltersDialog::on_rulesbuffer()
{
  gw_destroy_source(rulesbuffer_changed_event_id);
  rulesbuffer_changed_event_id = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, GSourceFunc(on_rulesbuffer_changed_timeout), gpointer(this), NULL);
}