Exemplo n.º 1
0
static GtkWidget* create_notepage_fileselect() {

  GtkWidget *grid_main;
  GtkWidget *grid_controls;
  GtkWidget *label1; // *label2;
  GtkWidget *file_select;
  GtkWidget *button_process_configfile;

  // create a treestore to store parsed data
  GtkTreeStore *store;
  GtkWidget *tree;

  store = gtk_tree_store_new (N_COLUMNS,
			      G_TYPE_STRING,
			      G_TYPE_STRING);

  // create a view
  tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));

  // view now holds a reference. Get rid of our own reference:
  g_object_unref (G_OBJECT (store));

  // setup tree view
  setup_config_file_treeview (GTK_TREE_VIEW(tree));
  
  // setup config file data  
  FileData * config_file = init_config_file(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree))));


  label1 = gtk_label_new("Select config file");
  gtk_label_set_line_wrap(GTK_LABEL(label1), TRUE);
  
  file_select = gtk_combo_box_text_new();
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(file_select), 
				 "gtk_config_file_1.conf");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(file_select), 
				 "gtk_config_file_2.conf");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(file_select), 
				 "pdpgui_gs_params_default.conf");
  g_signal_connect (file_select, "changed", G_CALLBACK(select_file), (gpointer)(config_file) );

  // aesthetic: give this a standard icon
  button_process_configfile = gtk_button_new_with_label ("Load from file");
  g_signal_connect (button_process_configfile, "clicked", 
		    G_CALLBACK(load_from_file), (gpointer)(config_file));

  grid_main = gtk_grid_new();
  grid_controls = gtk_grid_new();

  gtk_grid_attach (GTK_GRID(grid_controls), label1, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID(grid_controls), file_select, 0, 1, 1, 1);
  gtk_grid_attach (GTK_GRID(grid_controls), config_file->filename_label, 0, 2, 1, 1);
  gtk_grid_attach (GTK_GRID(grid_controls), button_process_configfile, 0, 3, 1, 1);
  //  gtk_widget_set_vexpand (GTK_WIDGET(grid_controls), TRUE);
  
  gtk_grid_attach (GTK_GRID(grid_main), grid_controls, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID(grid_main), tree, 1, 0, 1, 1);
  gtk_grid_set_column_spacing (GTK_GRID(grid_main), 30);
  gtk_widget_set_vexpand (GTK_WIDGET(grid_main), TRUE);
  gtk_widget_set_hexpand (GTK_WIDGET(grid_main), TRUE);


  gtk_widget_show_all(grid_main);

  g_signal_connect (G_OBJECT(grid_main), "destroy", 
		    G_CALLBACK (destroy_notepage_fileselect), 
		    (gpointer)config_file);

  return (grid_main);
  
}
Exemplo n.º 2
0
void load_config(){
    struct stat info;
    char cur_extra_section[PATHMAX];
    struct config_handle my_conf_handle;
    int i_tmp;
    long l_tmp;
    //Check if config file exists
    if (stat(CRASHLOG_CONF_PATH, &info) == 0) {
        LOGI("Loading specific crashlog config\n");

        my_conf_handle.first=NULL;
        my_conf_handle.current=NULL;
        if (init_config_file(CRASHLOG_CONF_PATH, &my_conf_handle)>=0){
            //General config - uptime
            //TO IMPROVE : general config strategy to define properly
            if (sk_exists(GENERAL_CONF_PATTERN,"uptime_frequency",&my_conf_handle)){
                char *tmp = get_value(GENERAL_CONF_PATTERN,"uptime_frequency",&my_conf_handle);
                if (tmp){
                    i_tmp = atoi(tmp);
                    if (i_tmp > 0){
                        gcurrent_uptime_hour_frequency = i_tmp;
                    }
                }
            }
            if (sk_exists(GENERAL_CONF_PATTERN,"sd_size_limit",&my_conf_handle)){
                char *tmp = get_value(GENERAL_CONF_PATTERN,"sd_size_limit",&my_conf_handle);
                if (tmp){
                    l_tmp = atol(tmp);
                    if (l_tmp > 0){
                        current_sd_size_limit = l_tmp;
                    }
                }
            }
            if (sk_exists(GENERAL_CONF_PATTERN,"serial_device_id",&my_conf_handle)){
                char *tmp = get_value(GENERAL_CONF_PATTERN,"serial_device_id",&my_conf_handle);
                if (tmp){
                    i_tmp = atoi(tmp);
                    if (i_tmp > 0){
                        g_current_serial_device_id = 1;
                    }
                }
            }
            if (sk_exists(GENERAL_CONF_PATTERN,"check_modem_version",&my_conf_handle)){
                char *tmp = get_value(GENERAL_CONF_PATTERN,"check_modem_version",&my_conf_handle);
                if (tmp){
                    i_tmp = atoi(tmp);
                    if (i_tmp > 0){
                        check_modem_version = 1;
                    } else {
                        check_modem_version = 0;
                    }
                    LOGI("Check modem version: %d", check_modem_version);
                }
            }
            load_config_by_pattern(NOTIFY_CONF_PATTERN,"matching_pattern",my_conf_handle);
            //ADD other config pattern HERE
            free_config_file(&my_conf_handle);
        }else{
            LOGI("specific crashlog config not found\n");
        }
    }
}