示例#1
0
int main (int argc, char **argv)
{
#ifdef ENABLE_NLS
  setlocale (LC_ALL, "");
  bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

  gtk_init(&argc, &argv);
#if GLIB_CHECK_VERSION (2, 24, 0)
  g_type_init();
#else 
  if (!g_thread_supported()) g_thread_init(NULL);
#endif

  gphpedit_debug_init ();
        
  main_window.prefmg = preferences_manager_new();

  /* Start of IPC communication */
  if (get_preferences_manager_single_instance_only(main_window.prefmg) && poke_existing_instance (argc - 1, argv + 1))
    return 0;

  main_window_create();
  main_window.tempmg = templates_manager_new();
  main_window.docmg = document_manager_new_full(argv, argc);
  gtk_main();
        
  /* it makes sense to install sigterm handler that would call this too */
  shutdown_ipc ();

  return 0;
}
示例#2
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);
}
示例#3
0
static void
language_css_init (Language_CSS * object)
{
    Language_CSSDetails *lgcssdet;
    lgcssdet = LANGUAGE_CSS_GET_PRIVATE(object);
    lgcssdet->prefmg = preferences_manager_new ();
    lgcssdet->symbolmg = symbol_manager_new ();
}
示例#4
0
static void
language_cobol_init (Language_COBOL * object)
{
  Language_COBOLDetails *lgcoboldet;
  lgcoboldet = LANGUAGE_COBOL_GET_PRIVATE(object);
  lgcoboldet->prefmg = preferences_manager_new ();
  lgcoboldet->symbolmg = symbol_manager_new ();
}
示例#5
0
void document_manager_session_reopen(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  int focus_tab=-1;
  gboolean focus_this_one = FALSE;
  PreferencesManager *prefmg = preferences_manager_new();
  GSList *files = get_preferences_manager_session_files(prefmg);
  if (g_slist_length (files)==0) {
    //session file exists but is empty
    //add a new untitled
    document_manager_add_new_document(docmg, TAB_FILE, NULL, 0);
  } else {
    GSList *walk;
    gchar *filename;
    for(walk = files; walk!= NULL; walk = g_slist_next(walk)) {
        filename = (gchar *)walk->data;
        /* filename contains possibly:
          file:///blah\n
          *file:///blah\n
          phphelp:function\n
          *phphelp:function\n
          preview:function\n
          *preview:function\n

        */
	filename = g_strdelimit (filename, "\n", 0);
        if (filename[0]=='*') {
          filename++;
          focus_this_one = TRUE;
        }
        if (g_str_has_prefix(filename, "phphelp:")){
          filename += 8;
          document_manager_add_new_document(docmg, TAB_HELP, filename, 0);
        } else if (g_str_has_prefix(filename, "preview:")){
          filename += 8;
          document_manager_add_new_document(docmg, TAB_PREVIEW, filename, 0);
        } else {
          if (filename){
          document_manager_switch_to_file_or_open(docmg, filename, 0);
          }
        }
        if (focus_this_one && (docmgdet->current_document)) {
            GtkWidget *document_widget;
            g_object_get(docmgdet->current_document, "editor_widget", &document_widget, NULL);
            focus_tab = gtk_notebook_page_num(GTK_NOTEBOOK(main_window.notebook_editor), document_widget);
        }
        focus_this_one=FALSE;
    }
  }
  gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor), focus_tab);
  g_object_unref(prefmg);
}
示例#6
0
static inline void change_current_folder(FilebrowserBackend *filebackend, const gchar *new_folder){
  FilebrowserBackendDetails *directory;
  directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend);
  if (!new_folder && *(new_folder)!=0) return;
  directory->current_folder= g_strdup(new_folder);
  PreferencesManager *prefmg = preferences_manager_new ();
  g_object_set(prefmg, "filebrowser_last_folder", directory->current_folder,NULL);
  g_object_unref(prefmg);
  gchar *real_path=filename_get_relative_path((gchar *)new_folder);
  if (!real_path) real_path=g_strdup(DEFAULT_DIR);
  g_signal_emit (G_OBJECT (filebackend), signals[CHANGE_FOLDER], 0, real_path); /* needed to update ui */
  g_free(real_path);
}
示例#7
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);
}
示例#8
0
void tab_sql_set_lexer(Document *document)
{
  Preferences_Manager *prefmg = preferences_manager_new ();
  GtkScintilla *scintilla = document_get_scintilla(document);
  gtk_scintilla_clear_document_style (scintilla);
  gtk_scintilla_set_lexer(scintilla, SCLEX_SQL);
  gtk_scintilla_set_style_bits(scintilla, 5);

  gchar *font =NULL;
  gint size, fore, back;
  gboolean italic, bold;

  get_preferences_manager_style_settings(prefmg, "c_default", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_font (scintilla,  SCE_C_DEFAULT, font);
  gtk_scintilla_style_set_fore (scintilla,  SCE_C_DEFAULT, fore);
  gtk_scintilla_style_set_back (scintilla,  SCE_C_DEFAULT, back);
  gtk_scintilla_style_set_size (scintilla,  SCE_C_DEFAULT, size);
  gtk_scintilla_style_set_italic (scintilla,  SCE_C_DEFAULT, italic);
  gtk_scintilla_style_set_bold (scintilla,  SCE_C_DEFAULT, bold);

  get_preferences_manager_style_settings(prefmg, "php_default", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_font (scintilla,  STYLE_BRACELIGHT, font);
  gtk_scintilla_style_set_fore (scintilla,  STYLE_BRACELIGHT, 16711680);// Matching bracket
  if(get_preferences_manager_higthlight_caret_line (prefmg))
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACELIGHT, get_preferences_manager_higthlight_caret_line_color(prefmg));
  else
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACELIGHT, back);
  gtk_scintilla_style_set_size (scintilla,  STYLE_BRACELIGHT, size);
  gtk_scintilla_style_set_italic (scintilla,  STYLE_BRACELIGHT, italic);
  gtk_scintilla_style_set_bold (scintilla,  STYLE_BRACELIGHT, TRUE);
  gtk_scintilla_style_set_font (scintilla,  STYLE_BRACEBAD, font);
  gtk_scintilla_style_set_fore (scintilla,  STYLE_BRACEBAD, 255);
  if(get_preferences_manager_higthlight_caret_line (prefmg))
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACEBAD, get_preferences_manager_higthlight_caret_line_color(prefmg));
  else
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACEBAD, back);
  gtk_scintilla_style_set_size (scintilla,  STYLE_BRACEBAD, size);
  gtk_scintilla_style_set_italic (scintilla,  STYLE_BRACEBAD, italic);
  gtk_scintilla_style_set_bold (scintilla,  STYLE_BRACEBAD, TRUE);

  gtk_scintilla_set_keywords(scintilla, 0, "ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE AUTO_INCREMENT BDB BEFORE BERKELEYDB BETWEEN BIGINT BINARY BLOB BOTH BTREE BY CALL CASCADE CASE CHANGE CHAR CHARACTER CHECK COLLATE COLUMN COLUMNS CONNECTION CONSTRAINT CREATE CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURSOR DATABASE DATABASES DAY_HOUR DAY_MINUTE DAY_SECOND DEC DECIMAL DECLARE DEFAULT DELAYED DELETE DESC DESCRIBE DISTINCT DISTINCTROW DIV DOUBLE DROP ELSE ELSEIF ENCLOSED ERRORS ESCAPED EXISTS EXPLAIN FALSE FIELDS FLOAT FOR FORCE FOREIGN FROM FULLTEXT GRANT GROUP HASH HAVING HIGH_PRIORITY HOUR_MINUTE HOUR_SECOND IF IGNORE IN INDEX INFILE INNER INNODB INOUT INSENSITIVE INSERT INT INTEGER INTERVAL INTO IS ITERATE JOIN KEY KEYS KILL LEADING LEAVE LEFT LIKE LIMIT LINES LOAD LOCALTIME LOCALTIMESTAMP LOCK LONG LONGBLOB LONGTEXT LOOP LOW_PRIORITY MASTER_SERVER_ID MATCH MEDIUMBLOB MEDIUMINT MEDIUMTEXT MIDDLEINT MINUTE_SECOND MOD MRG_MYISAM NATURAL NOT NULL NUMERIC ON OPTIMIZE OPTION OPTIONALLY OR ORDER OUT OUTER OUTFILE PRECISION PRIMARY PRIVILEGES PROCEDURE PURGE READ REAL REFERENCES REGEXP RENAME REPEAT REPLACE REQUIRE RESTRICT RETURN RETURNS REVOKE RIGHT RLIKE RTREE SELECT SENSITIVE SEPARATOR SET SHOW SMALLINT SOME SONAME SPATIAL SPECIFIC SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT SSL STARTING STRAIGHT_JOIN STRIPED TABLE TABLES TERMINATED THEN TINYBLOB TINYINT TINYTEXT TO TRAILING TRUE TYPES UNION UNIQUE UNLOCK UNSIGNED UNTIL UPDATE USAGE USE USER_RESOURCES USING VALUES VARBINARY VARCHAR VARCHARACTER VARYING WARNINGS WHEN WHERE WHILE WITH WRITE XOR YEAR_MONTH ZEROFILL");

  get_preferences_manager_style_settings(prefmg, "sql_word", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_back (scintilla, SCE_C_WORD, back);
  gtk_scintilla_style_set_font (scintilla, SCE_C_WORD, font);
  gtk_scintilla_style_set_fore (scintilla, SCE_C_WORD, fore);
  gtk_scintilla_style_set_size (scintilla, SCE_C_WORD, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_WORD, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_WORD, bold);

  get_preferences_manager_style_settings(prefmg, "sql_string", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_STRING, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_STRING, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_STRING, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_STRING, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_STRING, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_STRING, bold);

  get_preferences_manager_style_settings(prefmg, "sql_operator", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_OPERATOR, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_OPERATOR, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_OPERATOR, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_OPERATOR, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_OPERATOR, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_OPERATOR, bold);

  get_preferences_manager_style_settings(prefmg, "sql_comment", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_COMMENT, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_COMMENT, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_COMMENT, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_COMMENT, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_COMMENT, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_COMMENT, bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_COMMENTLINE, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_COMMENTLINE, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_COMMENTLINE, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_COMMENTLINE, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_COMMENTLINE, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_COMMENTLINE, bold);

  get_preferences_manager_style_settings(prefmg, "sql_number", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_NUMBER, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_NUMBER, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_NUMBER, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_NUMBER, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_NUMBER, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_NUMBER, bold);

  get_preferences_manager_style_settings(prefmg, "sql_identifier", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_IDENTIFIER, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_IDENTIFIER, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_IDENTIFIER, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_IDENTIFIER, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_IDENTIFIER, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_IDENTIFIER, bold);

  gtk_scintilla_colourise(scintilla, 0, -1);
  g_object_unref(prefmg);
}