示例#1
0
static gint main_window_key_press_event(GtkWidget *widget, GdkEventKey *event,gpointer user_data)
{
  MainWindow *main_window = (MainWindow *) user_data;
  if (main_window->notebook_editor != NULL) {
    documentable_check_externally_modified(document_manager_get_current_documentable(main_window->docmg));
    if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))==(GDK_CONTROL_MASK | GDK_SHIFT_MASK)) && (event->keyval == GDK_KEY_ISO_Left_Tab)) {
      // Hack, for some reason when shift is held down keyval comes through as GDK_ISO_Left_Tab not GDK_Tab
      if (gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window->notebook_editor)) == 0) {
        gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window->notebook_editor), gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_window->notebook_editor))-1);
      }
      else {
        gtk_notebook_prev_page(GTK_NOTEBOOK(main_window->notebook_editor));
      }
      return TRUE;
    }
    else if ((event->state & GDK_CONTROL_MASK)==GDK_CONTROL_MASK && (event->keyval == GDK_KEY_Tab)) {
      if (gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window->notebook_editor)) == gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_window->notebook_editor))-1) {
        gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window->notebook_editor),0);
      }
      else {
        gtk_notebook_next_page(GTK_NOTEBOOK(main_window->notebook_editor));
      }
      return TRUE;
    }
    else if ((event->state & GDK_MOD1_MASK)==GDK_MOD1_MASK && ((event->keyval >= GDK_KEY_0) && (event->keyval <= GDK_KEY_9))) {
      gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window->notebook_editor),event->keyval - ((event->keyval == GDK_KEY_0) ? (GDK_KEY_0 - 9) : (GDK_KEY_0 + 1)));
      return TRUE;
    }
  }
  return FALSE;
}
示例#2
0
void plugin_exec_with_num(GtkWidget *widget, gint num){
  Plugin *plugin;
  Documentable *doc = document_manager_get_current_documentable(main_window.docmg); 
  if (!doc) return;
  GtkPluginManagerMenu *menu= GTK_PLUGIN_MANAGER_MENU (widget);
  if (get_plugin_manager_items_count(menu->priv->plugmg) < num) return;
  plugin = get_plugin_by_num(menu->priv->plugmg, num);
  plugin_run(plugin, doc);
}
示例#3
0
static void plugin_exec (GtkWidget *widget, gpointer user_data)
{
  Plugin *plugin;
  Documentable *doc = document_manager_get_current_documentable(main_window.docmg);
  if (!doc) return;
  GtkPluginManagerMenu *menu= GTK_PLUGIN_MANAGER_MENU (user_data);
  
  plugin = get_plugin_by_name(menu->priv->plugmg, (gchar *) gtk_menu_item_get_label (GTK_MENU_ITEM(widget)));
  plugin_run(plugin, doc);
}
示例#4
0
static gboolean on_notebook_focus_tab(GtkNotebook *notebook,
                 GtkNotebookTab arg1, gpointer user_data)
{
  MainWindow *main_window = (MainWindow *) user_data;
  GtkWidget *document_widget;
  Documentable *doc = document_manager_get_current_documentable(main_window->docmg);
  g_object_get(doc, "editor_widget", &document_widget, NULL);
  gtk_widget_grab_focus(document_widget);
  return TRUE;
}
示例#5
0
static void document_manager_close_document_cb (DocumentManager *docmg, Documentable *doc, gpointer user_data)
{
  MainWindow *main_window = (MainWindow *) user_data;
  close_page(main_window, DOCUMENT(doc));
  update_app_title(main_window, document_manager_get_current_documentable(docmg));
  gchar *filename = documentable_get_filename (doc);
  gint ftype;
  g_object_get(doc, "type", &ftype, NULL);
  symbol_manager_purge_file (main_window->symbolmg, filename, ftype);
  g_free(filename);
}
示例#6
0
void main_window_create(char **argv, gint argc)
{
  main_window.is_app_closing = FALSE;
  main_window.prefmg = preferences_manager_new();
  main_window.tempmg = templates_manager_new();

  create_app_main_window(&main_window, _("gPHPEdit"));

  main_window.pbuilder = gtk_builder_new ();
  GError *error = NULL;
  guint res = gtk_builder_add_from_file (main_window.pbuilder, GPHPEDIT_UI_DIR "/gphpedit.ui", &error);
  if (!res) {
    g_critical ("Unable to load the UI file!");
    g_error_free(error);
    return ;
  }

  GtkWidget *prinbox = get_widget_from_builder(&main_window, "prinbox");
  gtk_widget_reparent (prinbox, GTK_WIDGET(main_window.window));

  /* add menu bar to main window */
  GtkWidget *menubox = get_widget_from_builder(&main_window, "menubox");
  gtk_widget_show (menubox);

  main_window.pmenu_hints = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);

  main_window.pmenu = menubar_new (&main_window);
  gtk_box_pack_start (GTK_BOX (menubox), main_window.pmenu, FALSE, FALSE, 0);
  gtk_widget_show_all (main_window.pmenu);

  GtkWidget *toolbox = get_widget_from_builder(&main_window, "toolbox");
  gtk_widget_show (toolbox);

  main_window.toolbar_main = toolbar_new (&main_window);
  gtk_box_pack_start (GTK_BOX (toolbox), main_window.toolbar_main, FALSE, FALSE, 0);
  if (get_preferences_manager_show_maintoolbar(main_window.prefmg)) gtk_widget_show (main_window.toolbar_main);

  main_window.symbolmg = symbol_manager_new();

  main_window_create_panes(&main_window);
  main_window_fill_panes(&main_window);
  main_window_create_appbar(&main_window);
  
  g_signal_connect (G_OBJECT (main_window.window), "delete_event", G_CALLBACK(main_window_delete_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "destroy", G_CALLBACK (main_window_destroy_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "key_press_event", G_CALLBACK (main_window_key_press_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "size_allocate", G_CALLBACK (main_window_resize), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "window-state-event", G_CALLBACK (main_window_state_changed), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "focus-in-event", G_CALLBACK (main_window_activate_focus), &main_window);

  main_window.stylemg = gtk_source_style_scheme_manager_new ();
  gchar *theme_dir = g_build_path (G_DIR_SEPARATOR_S, API_DIR, "themes", NULL);
  gtk_source_style_scheme_manager_prepend_search_path (main_window.stylemg, theme_dir);
  g_free(theme_dir);

  main_window.docmg = document_manager_new_full(argv, argc, &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "new_document", G_CALLBACK(document_manager_new_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "change_document", G_CALLBACK(document_manager_change_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "close_document", G_CALLBACK(document_manager_close_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "zoom_change", G_CALLBACK(document_manager_zoom_change_cb), &main_window);

  /* create side panel */
  create_side_panel(&main_window);

  update_app_title(&main_window, document_manager_get_current_documentable(main_window.docmg));

  gtk_widget_show(main_window.window);
}
示例#7
0
static gboolean main_window_activate_focus (GtkWidget *widget,GdkEventFocus *event, gpointer user_data)
{
  MainWindow *main_window = (MainWindow *) user_data;
  documentable_check_externally_modified(document_manager_get_current_documentable(main_window->docmg));
  return FALSE;
}
示例#8
0
void syntax_check_show(MainWindow *main_window)
{
  Documentable *doc = document_manager_get_current_documentable(main_window->docmg);
  gtk_syntax_check_window_run_check(GTK_SYNTAX_CHECK_WINDOW(main_window->pwin), doc, main_window);
  gtk_paned_set_position(GTK_PANED(main_window->pmain_vertical_pane), 200);
}
示例#9
0
static void goto_line(gchar *text)
{
  Documentable *doc = document_manager_get_current_documentable(main_window.docmg);
  if (doc) documentable_goto_line(doc, atoi(text));
}