Beispiel #1
0
static void close_page(MainWindow *main_window, Document *document)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  gint page_num;
  gint page_num_closing;
  gint current_active_tab;
  GtkWidget *document_widget;

  g_object_get(document, "editor_widget", &document_widget, NULL);
  page_num_closing = gtk_notebook_page_num(GTK_NOTEBOOK(main_window->notebook_editor), document_widget);
  current_active_tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window->notebook_editor));
  
  if (page_num_closing != current_active_tab) {
    page_num = current_active_tab;
  } else {
    // If there is a tab before the current one then set it as the active tab.
    page_num = page_num_closing - 1;
    // If the current tab is the 0th tab then set the current tab as 0 itself.
    // If there are are subsequent tabs, then this will set the next tab as active.
    if (page_num < 0) {
      page_num = 0;
    }  
  }

  if(document_manager_set_current_document_from_position(main_window->docmg, page_num)) {
    gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window->notebook_editor), page_num);
  }
  gtk_notebook_remove_page(GTK_NOTEBOOK(main_window->notebook_editor), page_num_closing);
}
Beispiel #2
0
void update_zoom_level(MainWindow *main_window, Documentable *doc)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  guint zoom_level = 100;
  if (doc) g_object_get(doc, "zoom_level", &zoom_level, NULL);
  gphpedit_statusbar_set_zoom_level(GPHPEDIT_STATUSBAR(main_window->appbar), zoom_level);
}
Beispiel #3
0
void document_manager_switch_to_file_or_open(DocumentManager *docmg, gchar *filename, gint line_number)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  Document *document;
  GSList *walk;
  /* need to check if filename is local before adding to the list */
  filename = g_strdup(filename);
  for (walk = docmgdet->editors; walk!=NULL; walk = g_slist_next(walk)) {
    document = walk->data;
    gchar *docfilename;
    GFile *file;
    g_object_get(document, "GFile", &file, NULL);
    docfilename = g_file_get_uri(file);
    gchar *filename_uri = filename_get_uri(filename);
    if (g_strcmp0(docfilename, filename_uri)==0) {
      GtkWidget *document_widget;
      g_object_get(document, "editor_widget", &document_widget, NULL);
      gtk_notebook_set_current_page( GTK_NOTEBOOK(main_window.notebook_editor), gtk_notebook_page_num(GTK_NOTEBOOK(main_window.notebook_editor), document_widget));
      documentable_goto_line(DOCUMENTABLE(docmgdet->current_document), line_number);
      g_free(docfilename);
      return ;
    }
    g_free(filename_uri);
    g_free(docfilename);
  }
  document_manager_add_new_document(docmg, TAB_FILE, filename, line_number);
  register_file_opened(filename);
  g_free(filename);
  return ;
}
Beispiel #4
0
static gchar *symbol_bd_sql_get_symbols_matches (Symbolizable *self, const gchar *symbol_prefix, gint flags)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  SymbolBdSQLDetails *symbolbddet;
  symbolbddet = SYMBOL_BD_SQL_GET_PRIVATE(self);
  symbolbddet->completion_prefix = (gchar *) symbol_prefix;
  symbolbddet->completion_string = NULL;

  if (symbol_bd_sql_has_cache(symbolbddet->cache_str, symbolbddet->cache_completion, symbolbddet->cache_flags, symbol_prefix, flags)){
    symbolbddet->completion_string = symbol_bd_get_autocomp_from_cache(symbolbddet->cache_str, symbolbddet->cache_completion, symbol_prefix);
  } else {
    symbolbddet->completion_tree = g_tree_new_full ((GCompareDataFunc) g_strcmp0, NULL, NULL,(GDestroyNotify) g_free);

    if (((flags & SYMBOL_ALL) == SYMBOL_ALL) || ((flags & SYMBOL_FUNCTION) == SYMBOL_FUNCTION)) {
      /* add api functions */
      g_tree_foreach (symbolbddet->sql_api_tree, add_api_item, symbolbddet);
    }
    g_tree_foreach (symbolbddet->completion_tree, make_result_string, symbolbddet);
    g_tree_destroy (symbolbddet->completion_tree);
    if (symbolbddet->completion_string) symbol_bd_sql_save_result_in_cache(symbolbddet, symbolbddet->completion_string->str, symbol_prefix);
  }

  if (symbolbddet->completion_string){
    gphpedit_debug_message(DEBUG_CLASSBROWSER, "prefix: %s autocomplete list:%s\n", symbol_prefix, symbolbddet->completion_string->str);
    return g_string_free(symbolbddet->completion_string, FALSE);
  }

  gphpedit_debug_message(DEBUG_CLASSBROWSER, "prefix: %s autocomplete list:%s\n", symbol_prefix, "null");
  return NULL;
}
Beispiel #5
0
void document_manager_refresh_properties_all(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  g_slist_foreach (docmgdet->editors, (GFunc) documentable_apply_preferences, NULL);
}
Beispiel #6
0
static void autoindent_brace_code (GtkScintilla *sci, PreferencesManager *pref)
{
  gint current_pos;
  gint current_line;
  gint previous_line;
  gint previous_line_indentation;
  gint previous_line_end;

  current_pos = gtk_scintilla_get_current_pos(sci);
  current_line = gtk_scintilla_line_from_position(sci, current_pos);

  gphpedit_debug (DEBUG_DOCUMENT);

  if (current_line>0) {
    gtk_scintilla_begin_undo_action(sci);
    previous_line = current_line-1;
    previous_line_indentation = gtk_scintilla_get_line_indentation(sci, previous_line);

    previous_line_end = gtk_scintilla_get_line_end_position(sci, previous_line);
    indent_line(sci, current_line, previous_line_indentation);
    gphpedit_debug_message (DEBUG_DOCUMENT, "previous_line=%d, previous_indent=%d\n", previous_line, previous_line_indentation);
    gint pos;
    gboolean tabs_instead_spaces;
    g_object_get(pref,"tabs_instead_spaces", &tabs_instead_spaces, NULL);
    if(tabs_instead_spaces){
      pos = gtk_scintilla_position_from_line(sci, current_line)+(previous_line_indentation/gtk_scintilla_get_tab_width(sci));
    } else {
      pos = gtk_scintilla_position_from_line(sci, current_line)+(previous_line_indentation);
    }
    gtk_scintilla_goto_pos(sci, pos);
    gtk_scintilla_end_undo_action(sci);
  }
}
Beispiel #7
0
GSList *document_manager_get_document_list (DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return NULL;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  return docmgdet->editors;
}
void on_tab_close_activate(GtkWidget *widget, Document *document)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    document_manager_try_close_document(main_window.docmg, document);
    classbrowser_update(GPHPEDIT_CLASSBROWSER(main_window.classbrowser));
    update_app_title(document_manager_get_current_document(main_window.docmg));
}
Beispiel #9
0
/*
* session_save relies on the fact that all tabs can be closed without 
* prompting, they should already be saved.  Also, the title won't be set
* afterwards.
*/
void document_manager_session_save(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  GSList *walk;
  Document *document;
  gboolean save_session;
  GSList *files=NULL;
  gchar *fileentry = NULL;

  PreferencesManager *prefmg = preferences_manager_new();
  g_object_get (prefmg, "save_session", &save_session, NULL);
  if (save_session) {
    for(walk = docmgdet->editors; walk!= NULL; walk = g_slist_next(walk)) {
      document = walk->data;
      gchar *entry = documentable_get_session_entry(DOCUMENTABLE(document));
      if (entry) {
        if (document == docmgdet->current_document) {
          fileentry = g_strdup_printf("*%s", entry);
        } else {
          fileentry = g_strdup (entry);
        }
        g_free(entry);
        files = g_slist_prepend (files, fileentry);
      }
    }
    files = g_slist_reverse(files);
  }
  set_preferences_manager_session_files(prefmg, files);
  g_object_unref(prefmg);
}
Beispiel #10
0
Documentable *document_manager_get_current_documentable (DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return NULL;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  return DOCUMENTABLE(docmgdet->current_document);
}
void close_page(Document *document)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    gint page_num;
    gint page_num_closing;
    gint current_active_tab;

    page_num_closing = gtk_notebook_page_num(GTK_NOTEBOOK(main_window.notebook_editor), document_get_editor_widget(document));
    current_active_tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window.notebook_editor));

    if (page_num_closing != current_active_tab) {
        page_num = current_active_tab;
    }
    else {
        // If there is a tab before the current one then set it as the active tab.
        page_num = page_num_closing - 1;
        // If the current tab is the 0th tab then set the current tab as 0 itself.
        // If there are are subsequent tabs, then this will set the next tab as active.
        if (page_num < 0) {
            page_num = 0;
        }
    }
    set_active_tab(page_num);
    gtk_notebook_remove_page(GTK_NOTEBOOK(main_window.notebook_editor), page_num_closing);
}
void classbrowser_show(void)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    gtk_paned_set_position(GTK_PANED(main_window.main_horizontal_pane), get_preferences_manager_classbrowser_get_size(main_window.prefmg));
    set_preferences_manager_parse_classbrowser_status(main_window.prefmg, FALSE);
    classbrowser_update(GPHPEDIT_CLASSBROWSER(main_window.classbrowser));
}
Beispiel #13
0
void document_need_reload_cb (Document *doc, gpointer user_data)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  DocumentLoader *loader = document_loader_new (GTK_WINDOW(main_window.window));
  g_signal_connect(G_OBJECT(loader), "done_refresh", G_CALLBACK(document_loader_done_refresh_cb), user_data);
  document_loader_reload_file(loader, doc);
}
Beispiel #14
0
void document_webkit_reload (Documentable *document_webkit)
{
  gphpedit_debug (DEBUG_DOCUMENT);
  g_return_if_fail(document_webkit);
  Document_WebkitDetails *docdet = DOCUMENT_WEBKIT_GET_PRIVATE(document_webkit);
  webkit_web_view_reload (docdet->help_view);
}
Beispiel #15
0
gchar *document_webkit_get_session_entry (Documentable  *doc)
{
  gphpedit_debug(DEBUG_DOCUMENT);
  gchar *result;
  Document_WebkitDetails *docdet;
  gboolean untitled;
  gchar *docfilename;

  if (!doc) return NULL;
  docdet = DOCUMENT_WEBKIT_GET_PRIVATE(doc);
  g_object_get(doc, "untitled", &untitled, NULL);
  if (untitled) return NULL;
  docfilename = documentable_get_filename(DOCUMENTABLE(doc));
  switch (docdet->type)
  {
    case TAB_HELP:
      result = g_strdup_printf ("phphelp:%s\n", docfilename);
      break;
    case TAB_PREVIEW:
      result = g_strdup_printf ("preview:%s\n",docfilename);
      break;
    default:
      result = g_strdup_printf ("%s\n",docfilename);
  }
  g_free(docfilename);
  return result;
}
Beispiel #16
0
gboolean document_manager_try_close_current_document(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return FALSE;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  return document_manager_try_close_document(docmg, docmgdet->current_document);
}
Beispiel #17
0
void _document_manager_set_current_document(DocumentManager *docmg, Document *document)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  docmgdet->current_document = document;
  g_signal_emit (G_OBJECT (docmg), signals[CHANGE_DOCUMENT], 0, docmgdet->current_document);
}
Beispiel #18
0
gint document_manager_get_document_count (DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return 0;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  if (!docmgdet->editors) return 0;
  return g_slist_length(docmgdet->editors);
}
Beispiel #19
0
/*
* symbol_manager_get_custom_symbols_list_by_filename
* return the list of symbols that match @symbol_type for a filename for the corresponding @ftype.
* Only one kind of symbol are allowed at a time.
* NOTE: the returned items are owned by the object and must not be freed.
* the return value must be free with g_list_free when no longer needed.
*/
GList *symbol_manager_get_custom_symbols_list_by_filename (SymbolManager *symbolmg, gint symbol_type, gchar *filename, gint ftype)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  if(!symbolmg || !filename) return NULL;
  Symbolizable *result = symbol_manager_get_symbolizable_for_type(symbolmg, ftype);
  if (!result) return NULL;
  return symbolizable_get_custom_symbols_list_by_filename (result, symbol_type, filename);
}
Beispiel #20
0
/*
* symbol_manager_get_calltip
* return a string containing the calltip for @symbol_name for the corresponding @ftype.
* @symbol_name must be a function name.
* NOTE: return value must be free with g_free when no longer needed.
*/
gchar *symbol_manager_get_calltip (SymbolManager *symbolmg, const gchar *symbol_name, gint ftype)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  if(!symbolmg || !symbol_name) return NULL;
  Symbolizable *result = symbol_manager_get_symbolizable_for_type(symbolmg, ftype);
  if (!result) return NULL;
  return symbolizable_get_calltip (result, symbol_name);
}
Beispiel #21
0
/*
* symbol_manager_get_symbols_matches
* return a string with all symbol that starts with @symbol_prefix, 
* following the symbol types from @flags parameter for the corresponding @ftype.
* will retreive all classes and functions that start with "str".
* NOTE: return value must be free with g_free when no longer needed.
*/
gchar *symbol_manager_get_symbols_matches (SymbolManager *symbolmg, const gchar *symbol_prefix, gint flags, gint ftype)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  if(!symbolmg || !symbol_prefix) return NULL;
  Symbolizable *result = symbol_manager_get_symbolizable_for_type(symbolmg, ftype);
  if (!result) return NULL;
  return symbolizable_get_symbols_matches (result, symbol_prefix, flags);
}
Beispiel #22
0
/*
* symbol_manager_get_classes
* return a string containing all classes for the corresponding @ftype.
* NOTE: return value must be free with g_free when no longer needed.
*/
gchar *symbol_manager_get_classes (SymbolManager *symbolmg, gint ftype)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  if(!symbolmg) return NULL;
  Symbolizable *result = symbol_manager_get_symbolizable_for_type(symbolmg, ftype);
  if (!result) return NULL;
  return symbolizable_get_classes (result);
}
void set_active_tab(page_num)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    if(document_manager_set_current_document_from_position(main_window.docmg, page_num)) {
        gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor), page_num);
    }
    update_app_title(document_manager_get_current_document(main_window.docmg));
}
Beispiel #24
0
void update_controls(MainWindow *main_window, Documentable *document)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  if (!document) return ;
  gboolean read_only, can_modify, preview;
  g_object_get(document, "read_only", &read_only, "can_modify", &can_modify, "can_preview", &preview, NULL);
  menubar_update_controls(MENUBAR(main_window->pmenu), can_modify, preview, read_only);
  toolbar_update_controls(TOOLBAR(main_window->toolbar_main), can_modify, read_only);
}
Beispiel #25
0
static void
document_manager_init (DocumentManager * object)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  DocumentManagerDetails *docdet;
  docdet = DOCUMENT_MANAGER_GET_PRIVATE(object);
  docdet->current_document = NULL;
  docdet->editors = NULL;
}
void quit_application()
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    g_object_unref(main_window.tempmg);
    is_app_closing = TRUE;
    g_object_unref(main_window.docmg);
    is_app_closing = FALSE;
    g_object_unref(main_window.prefmg);
}
Beispiel #27
0
void document_manager_get_document_preview(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  gchar *filename = documentable_get_filename(DOCUMENTABLE(docmgdet->current_document));
  document_manager_add_new_document(docmg, TAB_PREVIEW, filename, 0);
  g_free(filename);
}
Beispiel #28
0
static void side_panel_show(MainWindow *main_window)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  gint size;
  g_object_get(main_window->prefmg, "side_panel_size", &size, NULL);
  gtk_paned_set_position(GTK_PANED(main_window->pmain_horizontal_pane), size);
  g_object_set(main_window->prefmg, "side_panel_hidden", FALSE, NULL);
  classbrowser_update(GPHPEDIT_CLASSBROWSER(main_window->pclassbrowser));
}
Beispiel #29
0
void document_manager_get_context_help(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  gchar *buffer = documentable_get_current_selected_text(DOCUMENTABLE(docmgdet->current_document));
  if (buffer){
    document_manager_add_new_document(docmg, TAB_HELP, buffer, 0);
  }
}
Beispiel #30
0
// This procedure relies on the fact that all tabs will be closed without prompting
// for whether they need saving beforehand.  If in doubt, call can_all_tabs_be_saved
// and pay attention to the return value.
void document_manager_close_all_tabs(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  if (!docmgdet->editors) return;
  g_slist_foreach (docmgdet->editors, close_tab, docmg);
  docmgdet->editors = NULL;
  docmgdet->current_document = NULL;
}