Skip to content

Commit

Permalink
Adde some methods of GtkTreeView, GtkWidget, GtkWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
scorninpc committed May 27, 2019
1 parent 68dfd2b commit b6bc4f9
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 1 deletion.
8 changes: 8 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ extern "C"
gtkwidget.method<&GtkWidget_::set_margin_bottom>("set_margin_bottom");
gtkwidget.method<&GtkWidget_::get_margin_bottom>("get_margin_bottom");
gtkwidget.method<&GtkWidget_::set_size_request>("set_size_request");
gtkwidget.method<&GtkWidget_::get_size_request>("get_size_request");


// GtkContainer
Expand Down Expand Up @@ -433,6 +434,7 @@ extern "C"
gtkwindow.method<&GtkWindow_::set_titlebar>("set_titlebar");
gtkwindow.method<&GtkWindow_::get_titlebar>("get_titlebar");
gtkwindow.method<&GtkWindow_::set_interactive_debugging>("set_interactive_debugging");
gtkwindow.method<&GtkWindow_::get_size>("get_size");


// GtkDialog
Expand Down Expand Up @@ -587,6 +589,12 @@ extern "C"
gtktreeview.method<&GtkTreeView_::set_model>("set_model");
gtktreeview.method<&GtkTreeView_::get_selection>("get_selection");
gtktreeview.method<&GtkTreeView_::get_model>("get_model");
gtktreeview.method<&GtkTreeView_::expand_row>("expand_row");
gtktreeview.method<&GtkTreeView_::set_level_indentation>("set_level_indentation");
gtktreeview.method<&GtkTreeView_::set_show_expanders>("set_show_expanders");
gtktreeview.method<&GtkTreeView_::set_enable_tree_lines>("set_enable_tree_lines");
gtktreeview.method<&GtkTreeView_::row_expanded>("row_expanded");
gtktreeview.method<&GtkTreeView_::collapse_row>("collapse_row");


// GtkTreeViewColumn
Expand Down
63 changes: 62 additions & 1 deletion src/GtkTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,65 @@ Php::Value GtkTreeView_::get_selection()
GtkTreeSelection_ *return_parsed = new GtkTreeSelection_();
return_parsed->set_instance((gpointer *)ret);
return Php::Object("GtkTreeSelection", return_parsed);
}
}


Php::Value GtkTreeView_::expand_row(Php::Parameters &parameters)
{
std::string param_path = parameters[0];
GtkTreePath *path = gtk_tree_path_new_from_string(param_path.c_str());

bool open_all = false;
if(parameters.size() > 1) {
open_all = (bool)parameters[1];
}

//
bool ret = gtk_tree_view_expand_row(GTK_TREE_VIEW(instance), path, open_all);

return ret;
}

Php::Value GtkTreeView_::row_expanded(Php::Parameters &parameters)
{
std::string param_path = parameters[0];
GtkTreePath *path = gtk_tree_path_new_from_string(param_path.c_str());

//
bool ret = gtk_tree_view_row_expanded(GTK_TREE_VIEW(instance), path);

return ret;
}

Php::Value GtkTreeView_::collapse_row(Php::Parameters &parameters)
{
std::string param_path = parameters[0];
GtkTreePath *path = gtk_tree_path_new_from_string(param_path.c_str());

//
bool ret = gtk_tree_view_collapse_row(GTK_TREE_VIEW(instance), path);

return ret;
}


void GtkTreeView_::set_level_indentation(Php::Parameters &parameters)
{
gint indentation = (int)parameters[0];

gtk_tree_view_set_level_indentation(GTK_TREE_VIEW(instance), indentation);
}

void GtkTreeView_::set_show_expanders(Php::Parameters &parameters)
{
bool enabled = (bool)parameters[0];

gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(instance), enabled);
}

void GtkTreeView_::set_enable_tree_lines(Php::Parameters &parameters)
{
bool enabled = (bool)parameters[0];

gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(instance), enabled);
}
8 changes: 8 additions & 0 deletions src/GtkTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
Php::Value get_model();

Php::Value get_selection();

Php::Value expand_row(Php::Parameters &parameters);
void set_level_indentation(Php::Parameters &parameters);
void set_show_expanders(Php::Parameters &parameters);
void set_enable_tree_lines(Php::Parameters &parameters);

Php::Value row_expanded(Php::Parameters &parameters);
Php::Value collapse_row(Php::Parameters &parameters);
};

#endif
19 changes: 19 additions & 0 deletions src/GtkWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,23 @@ void GtkWidget_::set_size_request(Php::Parameters &parameters)

// Set default size
gtk_widget_set_size_request(GTK_WIDGET(instance), width, height);
}

Php::Value GtkWidget_::get_size_request(Php::Parameters &parameters)
{
// Verify sizes
int width = -1;
int height = -1;

// Set default size
gtk_widget_get_size_request(GTK_WIDGET(instance), &width, &height);

// Cria o retorno
Php::Value arr;
arr["width"] = width;
arr["height"] = height;
arr[0] = width;
arr[1] = height;

return arr;
}
1 change: 1 addition & 0 deletions src/GtkWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
Php::Value get_margin_bottom();

void set_size_request(Php::Parameters &parameters);
Php::Value get_size_request(Php::Parameters &parameters);
};

#endif
17 changes: 17 additions & 0 deletions src/GtkWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ Php::Value GtkWindow_::get_default_size()
return arr;
}

Php::Value GtkWindow_::get_size()
{
// Verify sizes
int width = -1;
int height = -1;

// Set default size
gtk_window_get_size(GTK_WINDOW(instance), &width, &height);

// Cria o retorno
Php::Value arr;
arr[0] = arr["width"] = width;
arr[1] = arr["height"] = height;

return arr;
}

/**
* Sets whether the user can resize a window.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/GtkWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@
* https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-set-interactive-debugging
*/
void set_interactive_debugging(Php::Parameters &parameters);

Php::Value get_size();
};

#endif

0 comments on commit b6bc4f9

Please sign in to comment.